What is toLocaleString()?
What is toLocaleString()?
根据这个MDN页面,toLocaleString
是关于转换日期的。然而,Chrome在多个字符串上公开了该函数。例如:
a = function () {};
a.toLocaleString(); // "function () {}"
什么是toLocaleString
?例如,为什么它暴露在空函数上?
它也可以在Object.prototype
上使用,所以几乎可以间接地在任何东西上使用。
对于Chrome,你可以看看V8的实现,它没有任何花哨的功能:
function ObjectToLocaleString() {
if (IS_NULL_OR_UNDEFINED(this) && !IS_UNDETECTABLE(this)) {
throw MakeTypeError("called_on_null_or_undefined",
["Object.prototype.toLocaleString"]);
}
return this.toString(); // <-- just calls toString
}
相关文章:
- toLocaleDateString和toLocaleString方法不尊重机器时区
- Is onfling available for html, html5
- jQuery is not loaded
- reactRedux is not defined
- ReferenceError: cordova is not defined @ng-cordova.min.js:7
- Jquery - table.row(tr) is undefined
- contentWindow.document.body is null
- Tomcat websocket is not working
- noty.js is returning undefined
- $routeParams is undefined
- NodeJS Multer is not working
- React, Webpack: bundle.js is not generated
- jQuery is not defined - WordPress footer.php
- 谷歌地图API v3:Initial View is Fine,but Gray Box with No Map if
- imageArray[i] = imageItem is incompatible
- GAPI Is Not Defined
- JS toLocaleString始终显示货币符号,而不考虑区域设置
- Angular2 rc1, where is shims_for_IE
- Is (!~index) faster than (index === -1)?
- What is toLocaleString()?