JavaScript 类型的包装对象(Typed Wrappers)

时间:2011-10-27    点击:132   
例如:

new Boolean(false)

会返回一个对象,该对象有一个 valueOf 方法会返回被包装的值。这其实完全没有必要,并且有时还令人困惑。不要使用 new Boolean、 new Number 或 new String。

此外也请避免使用 new Object 和 new Array。可使用 {} 和 [] 来代替。


--------------------------------------------------------------------------------

JavaScript has a set of typed wrappers. For example:

new Boolean(false)produces an object that has a valueOf method that returns the wrapped value. This turns out to be completely unnecessary and occasionally confusing. Don't use new Boolean or new Number or new String.

Also avoid new Object and new Array. Use {} and [] instead.

原文:http://demon.tw/programming/javascript-typed-wrappers.html
理解JSON:3分钟课程
能说明你的Javascript技术很烂的五个原因分析
input 和 textarea 输入框最大文字限制的jquery插件
VBS通过WMI监视注册表变动的代码
JavaScript Memoization 让函数也有记忆功能
> 返回     
地址:上海市普陀区胶州路941号长久商务中心 电话: QQ:
© Copyright 2012 上海网络 Product All Rights Reserved