JavaScript 類型的包裝對象(Typed Wrappers)
更新時間:2011年10月27日 10:01:25 作者:
JavaScript 有一套類型的包裝對象,需要的朋友可以參考下。
例如:
new Boolean(false)
會返回一個對象,該對象有一個 valueOf 方法會返回被包裝的值。這其實(shí)完全沒有必要,并且有時還令人困惑。不要使用 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
new Boolean(false)
會返回一個對象,該對象有一個 valueOf 方法會返回被包裝的值。這其實(shí)完全沒有必要,并且有時還令人困惑。不要使用 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
相關(guān)文章
javascript 面向?qū)ο缶幊?function也是類
function在javascript中用來創(chuàng)建函數(shù)或方法,但要想實(shí)現(xiàn)面向?qū)ο蠓绞降木幊蹋愂遣豢苫蛉钡慕巧?,而且是主角?/div> 2009-09-09
javascript面向?qū)ο缶幊?一) 實(shí)例代碼
javascript面向?qū)ο缶幊虒?shí)例代碼,代碼也算比較基礎(chǔ)了,不懂得朋友可以參考腳本之家之前發(fā)布的文章。2010-06-06
JavaScript 類型的包裝對象(Typed Wrappers)
JavaScript 有一套類型的包裝對象,需要的朋友可以參考下。2011-10-10
學(xué)習(xí)面向?qū)ο笾嫦驅(qū)ο蟮男g(shù)語
學(xué)習(xí)面向?qū)ο笾嫦驅(qū)ο蟮男g(shù)語,學(xué)習(xí)面向?qū)ο笤O(shè)計的朋友可以參考下。2010-11-11最新評論

