Home >Web Front-end >JS Tutorial >JavaScript typed wrappers (Typed Wrappers)_js object-oriented

JavaScript typed wrappers (Typed Wrappers)_js object-oriented

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-05-16 18:00:11945browse

For example:

new Boolean(false)

will return an object that has a valueOf method that returns the wrapped value. This is completely unnecessary and sometimes confusing. Do not use new Boolean, new Number, or new String.

Also avoid using new Object and new Array. {} and [] can be used instead.


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

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.

Original text: http://demon.tw/programming/javascript-typed-wrappers .html

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn