Basic JavaScript language learning note _ javascript skills

Source: Internet
Author: User
JavaScript is built on some very good ideas and a few very bad ideas. JavaScript is built on some very good ideas and a few very bad ideas.

Good ideas include functions, weak types, dynamic objects, and an expressive representation of the literal volume of objects,
Bad ideas include programming models based on global variables.

JavaScript Functions are top-level Objects Based on lexical scopes. Javascript is the first mainstream Lambda language. Compared with Java, JavaScript has more in common with Lisp and Scheme. It is a Lisp with a C coat. This makes JavaScript a very powerful language.

Nowadays, most languages are popular and require strong types. The principle is that a strong type allows the compiler to check for errors during compilation. The sooner we check for and fix errors, the lower the cost. Javascipt is a weak type language, so the JavaScript compiler cannot detect type errors. It turns out that a strong type does not make your testing work easy. On the other hand, a weak type is free. You do not need to create complex class layers, and do not need to make a forced shape.

JavaScript has a very powerful literal representation. By listing the components of objects, they can be simply created. This notation is an inspiration for me to create a popular data exchange format-JSON.

JavaScript depends on global variables for connection. All top-level variables of all compilation units are combined into a public namespace called a global object. This is a bad thing, because global variables are the devil and they are fundamental in JavaScript.
Reserved JavaScript words:

The Code is as follows:

abstract boolean break byte case catch char class const continue debugger default delete do double esle enum export extends false final finally float for function goto if implements import in instanceof int interface long native new null package private protected public return short static super switch synchronized this throw throws transient true try typeof var volatile void while with



Number: 64-bit floating point number
If a numeric literal has an exponential part, the knowledge of this literal is calculated from the power of the portion prior to e multiplied by the e portion after 10. So 100 and 1e2 are the same numbers.
The value NaN is a numerical value, indicating an operation result that cannot produce normal results. NaN is not equal to any value, including itself. You can use the isNaN (number) function to detect NaN.
The Infinity value indicates all values greater than 1.79769313486231570e + 308.
JavaScript has an object Math, which contains a set of methods that act on numbers. The Math. floor (number) method converts a number into an integer.
Character Set:
Character -- 16-bit (Unicode is a 16-bit Character Set)
JavaScript has no character type. To represent a single character, you only need to create a string containing only one character.
The \ u Convention allows you to specify a digit to represent a character bit. "A" = "\ u0041"
The string has a length attribute. For example, "seven". length is 5.
A string cannot be changed once it is created. However, it is easy to connect other strings through the + operator to obtain a new string. Two strings that contain identical characters and have the same character sequence are considered to be the same strings.
So: 'C' + 'A' + 'T' = 'cat'

Simple JavaScript types include numbers, strings, Boolean values (true and false), null values, and undefined values. All other values are objects.
An object is a property container, and each other property has a name and a value.
The attribute name can be any string including an empty string.
The attribute value can be any value except the underfined value.
Objects in JavaScript are classless. It has no constraints on the names and values of new attributes. Objects are suitable for collecting and managing data. Objects can include other objects, so they can be easily expressed as tree or graphic structures.
JavaScript includes a prototype chain feature that allows an object to inherit attributes of another object. Correct use of the tool can reduce the object initialization time and memory consumption.
Object literal:
Object literal provides a convenient representation for creating new objects. An object literal is surrounded by zero or multiple "name/value" pairs in a pair of curly braces. Objects can appear where expressions are allowed.
Var empty_object = {};
Var stooge = {
"First-name": "Jerome ",
"Last-name": "Howard"
};
The attribute name can be any string including the hole string. In the object literal, if the attribute name is a valid JavaScript identifier and is not a reserved word, it is not mandatory to enclose the attribute name in quotation marks. Therefore, it is required to enclose "first-name" in quotation marks, but it is optional to enclose first_name. Commas (,) are used to separate multiple "name/value" pairs.
The attribute value can be obtained from any expression including another object literal. Objects can be nested.

The Code is as follows:

var flight = { airline:"Oceanic", number:815, departure: { IATA:"SYD", time:"2004-09-22 14:55", city:"Sydney" }, arrival: { IATA:"LAX", time:"2004-09-23 10:42", city:"Los Angeles" } };
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.