Java Scripting Codes

Break Loop Code
for (i=0;i<8;i++)
{
if (i==4)
{
break;
}
x=x + "The number is " + i + "<br />";
}
Continue Loop Code
for (i=0;i<=8;i++)
{
if (i==4)
{
continue;
}
x=x + "The number is " + i + "<br />";
}

While Loop Code
while (variable<endvalue)
{
code to be executed
}while (i<4)
{
x=x + "The number is " + i + "<br />";
i++;
}
For Loop Code
for (variable=startvalue;variable<endvalue;variable=variable+increment)
{
code to be executed
}
Example
for (i=0; i<4; i++)
{
x=x + "The number is " + i + "<br />";
}
Switch Case code
var day=new Date().getDay();
switch (day)
{
case 0:
x="Today it's Sunday";
break;
case 1:
x="Today it's Monday";
break;
case 2:
x="Today it's Tuesday";
break;
case 3:
x="Today it's Wednesday";
break;
}
RegExp Code
var patt=new RegExp(pattern,modifiers);
or more simply:
var patt=/pattern/modifiers;
Function Code
function functionname()
{
some code
}
Variable Code
var myname="zain";
document.getElementById("myP").innerHTML=myname;
Date Code
new Date() // current date and time
new Date(seconds) //seconds since 200/05/05
new Date(dateString)
new Date(year, month, day, hours, minutes, seconds, milliseconds)var myDate=new Date();var myDate=new Date();
myDate.setDate(myDate.getDate()+5)
Math Code
var x=Math.PI;
var y=Math.sqrt(16);Math.E
Use Mtheod
Math.PI
Math.SQRT2
Math.SQRT1_2
Math.LN2
Math.LN10
Math.LOG2E
Example
Math.LOG10Edocument.write(Math.round(4.7));
Coment Code
// Write to a heading:
document.getElementById("myH1").innerHTML="Welcome to my Homepage";
// Write to a paragraph:
document.getElementById("myP").innerHTML="This is my first paragraph.";
JS ARRY Code
var myCars=new Array();
myCars[0]="Suzuki";
myCars[1]="Corolla"myCars[2]="BMW";
var myCars=new Array("Suzuki","Corolla","BMW");
var myCars=["Suzuki","Corolla","BMW"]; 
document.write(myCars[0]);
Suzuki
myCars[0]="Opel";
document.write(myCars[0]);
Opel

Friends