JavaScript composition
A complete JavaScript implementation is made up of the following 3 different parts:
ECMAScript: Describes the grammar and basic objects of the language;
The Document Object model, or DOM, is a description of the methods and interfaces for handling Web page content;
Browser object models (Browser object model, BOM): Describes the methods and interfaces that interact with the browser.
Variable
Variable type: Object String function Boolean undefined null number
JavaScript is a weak type, declaring a variable cannot declare a data type: int i=0;
can only be i=0 by VAR; declaring variables, unlike var in C #, is not a type inference in C #
JS is a dynamic type, so var i=0;i= "ABC"; it's legal.
Determining variable Initialization
The true and False in JS
True: true, not 0 digits, non-empty string, non-empty object
False: False, number 0, empty string, empty object, undefined
var a=false or a=0 or a=null or a=undefined or a= '
if (a) false
Operator
Programming languages are basically the same, listing Special:
1. = = =,! ===
A==b first converts the type, then compares, A===b does not convert the type, directly than
var a = 1;
var B = "1";
Alert (A = = B); True
Alert (A = = B); False
2 | | Returns the first value that is not false (the object can also), or the last value if all is false, the returned result is not necessarily a Boolean value
var a=2;
var b=0;
var c=b| | A
Window.alert (c); Output 2
Process Control Statements
Determine if else, switch case
Loop while (does while) for
JS does not have a foreach but can be used like a foreach
for (var item in data)
{
alert (item);
}
Jump out of break, continue
JavaScript Basics-variable-operator-flow control statements