JavaScript Basics-types, values, and variables

Source: Internet
Author: User

Objects and arrays are mutable types; The string is immutable: You can access text anywhere in the string, but JavaScript does not provide a way to modify the text content of the string.

JavaScript variables are untyped (untyped), variables can be assigned to any type of value, and the same variable can be re-assigned to different types of values. Use the VAR keyword to declare (declare) variables. JavaScript uses lexical scopes (lexical scoping). A variable that is not declared within any function is called a global variable, which is visible anywhere in the JavaScript program, variable. all numbers in JavaScript are represented by floating-point numbers. JavaScript support for octal varies, preferably without octal. how JavaScript is used to express floating-point numbers: [digits] [. digits] [(e|e) [(+|-)] digits]Infinity (Infinity) or-infinity (negative infinity) 0/0 insignificant, is a non-numeric value, with Nan means that JavaScript predefined global variables Infinity and Nan, used to represent both infinity and non-numeric values. The non-numeric value Nan in JavaScript is a bit special: it's not equal to anyone, including yourself. That is, you cannot use X==nan to determine if X is Nan, but you should use X!=x to judge (and only if the result of an expression is true if X equals Nan). The function isNaN () is similar to true if the argument is Nan or is a non-numeric value such as a string and an object. The function Isfinite () returns True when the parameter is not Nan, infinity, or-infinity.    About zero value: var zero = 0;    Normal 0 value var Negz =-0;   Negative 0 value Zero = = Negz;   =>true: Positive zero value and negative 0 value equal 1/zero = = = 1/negz; =>false: Positive infinity and negative infinity inequality it is important to note that the accuracy of fractions in JavaScript is debatable, for example, due to rounding errors, the approximate difference between 0.3 and 0.2 does not actually equal the approximate difference between 0.2 and 0.1! Therefore, in the financial aspects of programming can be done by using small units of integer operations, to avoid rounding error problems. If you want to assign a value to a variable or property, or pass in a function as a parameter, the best choice between undefined and null is to use null (undefined is a vacancy for system-level, unexpected, or similar-error values, and NULL is for program-level, The vacancy of a normal or expected value. )。

JavaScript Basics-types, values, and variables

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.