Three-head operation:such asvar a=10;

var b=12;

If true, execute a, otherwise execute b

var ishide=true;

If the if statement is as follows

if (ishide) {
} else {

Trinocular operation instead of if


Analyzing conditions?True execution statement:Untrue execution statement.

If the condition is satisfied, the result is returned.

Condition not met:result of execution

Simplified if judgment

continue Skip this cycle:Cannot write trinocular operation


for (var i=0;i<5;i ++) {
if (i == 3)
continue;skip the loop i=3 and do not execute;
Others still perform.

break:terminate the entire loop;By default, only the next cycle is terminated. If other cycles are to be terminated,You need to name the loop.


for (var i=0;i<5;i ++) {
if (i == 3)
break;terminate the entire loop when the loop reaches i=3.
name:for (var i=0;i<5;i ++) {
for (var j=0;j<5;j ++) {
break name //Terminate the two loops

Objects store data,Is stored in the properties of the object:

An object is a complex type of data,In the object we can store any type of data

The first type:attribute operation 1 The first type of attribute operation is a set of hard-coded values.You cannot use variables.

Read operation obj.property name

Write operation obj.attribute name=property value;

obj.key=val;key-value pairs;

Such as

var obj=();
obj.name="leo";This way of writing is that the first attribute name is written to death.
obj.age=40;under console.log (obj.name) ;.
console.log (obj.w);//Note that the first property operation is a hard-written value,You can't use the variable obj.w so you think you are looking for the w property of obj.

The second attribute operation does the second attribute operation,Receives a string,Strings can be stored in variables,Can directly write obj [variable call]

Read obj ["property name]

obj ["attribute name"]=attribute value;

obj ["key"]=val;

Note the second

Such as

var obj=();
obj ["name"]="leo";
obj ["age"]=40;
obj ["gender"]="female";
obj ["width"]="180px";
obj ["height"]="180px";
obj ["children"]=["Daming", "Xiaoming", "Sanming"];
var w="width";
console.log (obj [w]);//The second attribute operation,Accepts a string,Strings can be stored in variables,You can write obj [variable call] directly;
alert ("name" in obj);//obj returns true if it has a name attribute, otherwise it returns false

Determines whether this object has this property

Returns true or false

for (var s in obj) {find all attributes s of obj will turn into the attribute name of arr in turn
console.log (s, obj [s]);The property name that should be.
To use only use the second name.
The type of s is a string.
} s is the attribute name obj [s] is the attribute value of the corresponding attribute name.

for in can be used to loop over objects and arrays

The for loop can only be used to loop. Array-like arrays (a group of elements) cannot be used to loop a group of objects.

###whilesentence ###
Starting value
while (judgment condition) {
Execute statement
##switch ##
switch (what to judge) {
case:judge content;
 //After the condition is satisfied, the execution statement will execute all the code in the case.
It only ends when you meet break
Execute statement
 If there is no break, you will encounter puncture and execute all code.
default://All the above judgments are not true


switch (a) {
case 10://When a == 10;
console.logo (";;;;") Add break after statement
break;//when a == 10
case 15://When a == 15;
console.logo ("ppppp")
default://All the above judgments are not true

to sum up

  • Previous PHP implements BootStrap form function for login and registration
  • Next The correct way to set a 404 error page in IIS75 and above in win2008 r2