break
for(var i=0;i<10;i++){
if(i==3) break;
console.log(i) //1,2,3
}
switch , case
function main(arg){
switch(arg){
case 1:
console.log(1);
break;
case 2:
console.log(2);
break;
case 3:
console.log(3);
break;
}
}
main(3); //3
try , catch
try{
console.log(main)
}catch(e){
console.log(e) //main is not defined
}
continue
for(var i=0;i<5;i++){
if(i==2) continue;
console.log(i) //0,1,3,4
}
default
function main(arg){
switch(arg){
case 1:
console.log(1);
break;
case 2:
console.log(2);
break;
case 3:
console.log(3);
break;
default:
console.log(null)
}
}
main(4); //null
delete
var person = {
name:"sao",
age:"18"
}
console.log(person.name); //sao
delete person.name;
console.log(person.name); //undefined
do while , while
var num = 6; do{ console.log(num); //6 num++ } while(num<5);
/*----------------------*/
var num = 3;
while(num<5){
console.log(num); //3,4
num++
};
if else
var i = 0
if(i==0){
console.log(true) //true
}
finally
try{
console.log(main)
}catch(e){
console.log(e) //main is not defined
}finally{
console.log("finally") //finally
}
for in
var person = {
name:"sao",
age:"18"
}
for(var i in person){
console.log(i) //name,age
}
void , function
void function(){
console.log("hello") //hello
}()
var , new
var name = new String("sao");
console.log(name) //sao
return
function main(){
return console.log("hello")
}
main();
throw , typeof
try{
throw null
console.log(main)
}catch(e){
console.log(typeof e) //object
}
this
function main(){
console.log(this)
}
main.call(new String("sao"));
with
var person = {
name:"sao",
age:"18"
}
with(person){
console.log(name)
}
instanceof
var main = new String("sao");
console.log(typeof main);
console.log(main instanceof String);
PS:
void function(){
try{
var main = new Object();
main.name = "sao";
main.age = new Number("18");
do{
with(main){
if(age == 18 && age instanceof Number){
throw 0;
}else{
throw 1;
}
}
}while(main.age != 18)
}catch(e){
switch(e){
case 0:
for(var i in main){
if(typeof main[i]=="string"){
delete main.name
continue;
}
}
break;
case 1:
break;
default:
}
}finally{
(function(){
alert(this.age) //18
}).call(main)
return;
}
}()