Preface
//standard written
funciton helloFun () {
alert (" hellow world ")
}
//variables in the form of written
var helloFun=function () {
alert (" hellow world ")
}
//function can have parameters, it is different for the weak type
var helloFun=function (MSG) {
alert (MSG);
}

//function call helloFun (" hello world ");

conditional statement

var//switch instance inputNumber=document. The getElementByID (" type ");

the switch (inputNumber) {
case 1:
alert (" type 1 ");
break;
case 2:
alert (" type 2 ");
break;
case 3:
alert (" type 3 ");
break;
default:
alert (" throw new Exception () ");
break;
}

var inputAge=//if the instance document. The getElementByID (" age ");
if (inputAge> 1 &&inputAge<18)
{
alert (" minor ");

} else if (inputAge>=18 &&inputAge<70)
{
alert (" adults ");

} else if (inputAge>=70)
{
alert (" elderly ")
}
the else
{
alert (" fill out the form incorrectly ");
}


loop statements//a for loop
var arr=[1, 2, 3]
the for (int I=0; j=arr length; i the console. The log (arr [I]);//firefox console as you can see the results
}

in fact, in the world, for code execution performance also is to have cultured very much, we are in the for statement written performance is not wrong, but if written in the following, the performance would decline, because every time it
traversed, go to find the length of Arr.

//a for loop
var arr=[1, 2, 3]
the for (int I=0; i the console. The log (arr [I]);//performance is not good
}

ok, for JS programming basics just write here, starting from next time, would like to introduce the related knowledge of jquery, thanks for reading!


This concludes the body part