10 things that are confusing about JavaScript

Source: Internet
Author: User
Tags numeric value

JavaScript, the world's most popular programming language, has been labeled as a nightmare for Web development designers, and while the real nightmare is Domapi, the scripting language that has been exploited by a large number of developers and designers to augment their Web front end is now gaining weight, though, JavaScript still has a lot of confusing things to do.

1. It is named after Java, but not Java

It was originally called Mocha, then renamed to LiveScript, and finally decided to name JavaScript, according to historical records, Java's name and the cooperation between Netscape and Sun, in Exchange, Netscape in their popular browser created a Java Runtime. It is worth mentioning that the name of the introduction of nearly a joke, you know, LiveScript and Java in the client script has a hostile relationship.

Anyway, one of the things that people later have to clarify is that JavaScript has nothing to do with Java.

2. Null is an object?

Look at this code and it returns object.

This is really confusing, how can it be an object if NULL represents a null value? To put it simply, it was the first version of JavaScript that was wrong, and it was even borrowed directly from Microsoft's JScript.

3. Nan!== nan

Nan, which represents a non-numeric value, however, the problem is that Nan is not equal to anything, not even to itself.

This is obviously not true, in fact, if you want to determine that a value is really NaN, you need to use the isNaN () function.

4. Global variables

The

Dependency on global variables has always been considered the worst part of JavaScript (ECMA JavaScript 5 has removed global variables, see ECMA to launch JavaScript 5-translator). For simple pages, this doesn't matter, but complex pages, if it contains a lot of JavaScript scripts, you can hardly know where a global variable is declared, and if several global variables are accidentally duplicate names, an error is raised.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.