Home  >  Article  >  Web Front-end  >  What is the original design intention of null and undefined in js

What is the original design intention of null and undefined in js

一个新手
一个新手Original
2017-09-26 09:50:511922browse

null represents a "null" value, which is the same as 0 and the empty string '' is different, 0 is a numerical value, '' means the length is # A string of ##0, while null means "empty".

In other languages, there are also expressions similar to JavaScript's null, such as Java also uses null, Swift uses nil, Python uses None means. However, in JavaScript, there is also a null similar to undefined, which means "Undefined".

The designers of JavaScript hope to use null to represent an empty value, and undefined means the value is undefined. Facts have proved that this is of no use, and the difference between the two is of little significance. In most cases, we should use null.

*undefined is only useful when determining whether function parameters are passed.

The above is the detailed content of What is the original design intention of null and undefined in js. For more information, please follow other related articles on the PHP Chinese website!

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