first, write in front of the words
1, we have heard, in some places, JavaScript will be used as an entry-level programming language, because it is relatively easy to learn, easy to understand.
2, JavaScript is an out-and-out programming language, since it is a language, it should have its own grammar, it is imperative to master its grammar.
3. Don't try to memorize all of its grammar and keywords, in fact, almost no one can do it.
4, no one dares to say, learn JavaScript1 years or years can be called undefeated myth, persist, will let you go farther, only in this way, you may appreciate the more beautiful scenery.
5. Make a plan that suits you, choose a book that suits you, and take your first step bravely.
Ii. Basic JavaScript concepts
1. JavaScript is a kind of object-based interpretive language developed by Netscape Company and Sun Company, which can also be called literal translation language.
2, JavaScript relies on the interpreter, it has a good cross-platform, and because of this, its application is now inclined to but not limited to the web side.
3. JavaScript can be used for user interaction and data processing.
4. JavaScript is a weak type of data type error-prone language (poke here to learn more).
Third, JavaScript variables
1. JavaScript allows you to define variables without declaring the variable data type;
2, the definition of variable syntax:var variable name ; var (abbreviated in English variable) is a JavaScript keyword, see the following example:
var // define one variable at a time var myheight, MyAge; // You can also define multiple variables at once
3. Naming rules for variable names: Do not allow spaces and punctuation in variable names (except the dollar sign "$"); allow letters, numbers (the first letter is not allowed to be numbers), underscores, dollar signs, or the name of a "camel";
4, plus Var and no var define the difference: The scope is different, plus var variable is a local variable, no VAR is a global variable;
var myAge =; function Myro () { var myAge =; Console.log (MyAge); } Myro (); // Console.log (myAge); // at
iv. JavaScript data types
1, JavaScript is the same as other programming languages, variables also have the following data types:
varMyVar =NewString;//declare a variable of a string type--in double or single quotation marksvarMyVar =Newnumber;//declare a variable of a numeric type--integer or decimal (floating-point number)varMyVar =NewBoolean;//declares a Boolean type of variable--true or false
varMyVar =NewArray;//declaring a variable of an array typevarMyVar =NewObject;//declaring a variable of an object type
Undefined This value indicates that the variable does not contain a value, that is undefined, thatnull is empty and is usually used to empty the variable.
2. JavaScript data types include: basic data types and composite data types, basic data types include: String, Number, Boolean, Undefined, Null, composite data types include arrays, objects, and so on.
3, typeof is a unary operator, we can use typeof () to detect the variable data type, parentheses can be any type.
varMYVAR0 =-0.5;varMYVAR2 =NaN;varMYVAR3 =Number.MAX_VALUE;varMYVAR4 =Infinity;varMYVAR5 = ' Hello World ';varMYVAR6 =true;varMYVAR7 =window;varMYVAR8 =document;varMYVAR9 =NULL;varMyVar10 =undefined;varMyVar11 =Date;varMyVar12 =eval;varMyVar13 = {A:1,b:2,c:3};varMyVar14 = [' Hello ', ' World '];
document.write (typeof(myVar0) + ' <br/> ');// Numberdocument.write (typeof(myVar1) + ' <br/> ');// Numberdocument.write (typeof(MYVAR2) + ' <br/> ');// Numberdocument.write (typeof(MYVAR3) + ' <br/> ');// Numberdocument.write (typeof(MYVAR4) + ' <br/> ');// Numberdocument.write (typeof(MYVAR5) + ' <br/> ');//stringdocument.write (typeof(MYVAR6) + ' <br/> ');//Booleandocument.write (typeof(MYVAR7) + ' <br/> ');//Objectdocument.write (typeof(MYVAR8) + ' <br/> ');//Objectdocument.write (typeof(MYVAR9) + ' <br/> ');//Objectdocument.write (typeof(myVar10) + ' <br/> ');//undefineddocument.write (typeof(MYVAR11) + ' <br/> ');//functiondocument.write (typeof(myVar12) + ' <br/> ');//functiondocument.write (typeof(myVar13) + ' <br/> ');//Objectdocument.write (typeof(myVar14) + ' <br/> ');//ObjectvarMyVar15 =Abc;document.write (typeof(MYVAR15) + ' <br/> ');//uncaught referenceerror:abc is not defined
Try it yourself and you'll find the big difference, especially the last one.
JavaScript Learning Notes-Grammar Basics 1.1