The cancer of JavaScript

Source: Internet
Author: User

0. Introduction

There are many problematic features that are difficult to avoid in JavaScript. The next one by one is revealed.

1. Global variables

Of all the bad features of JavaScript, the worst is the dependency of global variables. Global variables make it harder to run separate subroutines in the same program.

2. Scope

JavaScript is the syntax of Class C, but does not provide a block-level scope for Class C.

3. Automatic insertion of semicolons

JavaScript has an automatic fix mechanism that attempts to fix a defective program by automatically inserting semicolons, but it can mask more serious errors.

4. Reserved words

Too many words are reserved in JavaScript and they cannot be used to name variables or functions (in most execution environments, some of the keywords are available).

5. Unicode characters

At the beginning of JavaScript design, Unicode is expected to have only 65,536 characters. In fact, how many million characters are Unicode now. This also leads to JavaScript thinking that a pair of characters is two different characters (Unicode treats a pair of characters as a single character)

6, typeof

Do not expect TypeOf to return the type. For example, null or a detection object, and the detection of a regular may return function or object.

7, parseint

Parseint converts a string to an integer that stops parsing when it encounters a non-digit. In addition, if the first character is 0, the value is also followed by a 8 binary.

8, operator (+)

The + operator can be used for addition operations or string joins, and how the execution will depend on its parameter type.

9. Floating point number

Binary floating-point numbers do not correctly handle decimal decimals, so 0.1+0.2 is not equal to 0.3.

10, NaN

Nan is a special quantity value, which indicates that it is not a number. is also the only JavaScript value that does not equal itself.

11. Pseudo-Array

JavaScript does not have a real array, and even an array is modeled by object, if it does not reach the point where the real array is. The typeof operator also does not recognize arrays and objects.

12. False value

JavaScript contains many false values, such as: 0, NaN, ' ', false, null, undefined

13, hasOwnProperty

The hasOwnProperty method is used as a filter to avoid the for. In statement, but hasOwnProperty is a common method, so it can be overridden.

14. Objects

JavaScript objects are never really empty objects, because member properties can be obtained from the prototype chain.

The cancer of JavaScript

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.