JavaScript basic syntax
1. Operators
The operator is a series of symbols that complete the operation, which has seven classes:
Assignment operators (=,+=,-=,*=,/=,%=,<<=,>>=,|=,&=), arithmetic operators (+,-, *,/,++,--,%), Comparison operators (>,<,<=,>=,==,== =,!=,!==), logical operators (| |,&&,!), conditional operations (?:), displacement operators (|,&,<<,>>,~,^), and string operators (+).
Maybe a lot of people don't know what "= = =".
Here, I explain to you, in javascript "= = =" is congruent only "= = =" On both sides of the memory address is equal to return the true
and the "= =" will return TRUE if the value is equal.
For example: Null==undefined will return true, but null===undefined will return false!
2. Expression
The combination of operators and operands is called an expression, usually divided into four classes: an assignment expression, an arithmetic expression, a Boolean expression, and a string expression.
3. Statements
A JavaScript program is made up of several statements, which are instructions for writing a program.
JavaScript provides complete BASIC programming statements: An assignment statement, a switch SELECT statement, a while loop statement, a For Loop statement, a For Each loop statement, a Do and loop statement, a break loop abort statement, Continue loop interrupt statement, with statement, Try...catch statement, if statement (IF). Else,if...else If ... ), let statement.
4. Functions
A function is a named statement segment that can be referenced and executed as a whole. There are a few things to note about using functions:
1) functions are defined by the keyword function (which can also be constructed by the function constructor);
2) functions defined with the function keyword can be called anywhere within a scope (including statements that define a function), and must be defined with the VAR keyword to be called;
3) The function name is the name that is referenced when the function is called, it is sensitive to case, and the function is not written in the wrong name when it is called;
4) The parameter represents the value passed to the function or operation, which can be a constant, or a variable, or a function, which can be accessed through the arguments object (the arguments object is a pseudo-array, the property callee refers to the called function) to access all parameters;
5) The return statement is used to return the value of an expression.
6) The yield statement throws an expression and interrupts the function execution until the next call to next.
5. Objects
An important function of JavaScript is the object-oriented function, which can be developed in a more intuitive, modular and reusable way through object-based programming.
6. Events
The action that occurs when a user interacts with a Web page, called an event. Events can be raised by the user, or the page may change, and even events that you can't see (such as an Ajax interactive Progress Change).
Most things are triggered by the user's actions, such as: the user presses the mouse button, the Click event is generated, if the mouse pointer on the link to move, resulting in mouseover events and so on.
In JavaScript, events are often used in support of event handlers.
7. Variables
such as var myvariable = "some value";
The variable has its type, the type of myvariable in the previous example is string (string)
Common types supported by JavaScript are:
Object: Objects
Array: arrays
Number: Numbers;
Boolean: Boolean, with only true and false two values, which are the least memory-intensive of all types;
NULL: A null value, the unique value is null;
Undefined: No variables defined and assigned
In fact, the JavaScript variable is a weakly variable type, and you assign it to him as a string. It's a number, he's plastic.
Is true and false he is the Boolean type (note that it cannot be quoted, otherwise it will be treated as a string).
The above describes the basic JavaScript Basics JavaScript syntax, I hope to help you.
Basics of getting Started with JavaScript