console.log(typeof([]));//object
console.log(typeof({}));//object
console.log(typeof(NaN));//number
console.log(typeof(Null));//undefined
console.log(typeof(('abcd')*5));//number
console.log(typeof(('abcd')+5));//string
console.log(1 && 2);//2
console.log(1 & 2);//0
console.log(1 || 2);//1
console.log(1 | 2);//3
console.log(NaN==NaN);//false
console.log(true+1);//2
window.val=1;
var json={
val:10,
dbl:function(){
this.val*=2;
}
};
json.dbl();
var dbl=json.dbl;
dbl();
json.dbl.call(window);
alert(window.val+json.val);
(function(){
var val=1;
var json={
val:10,
dbl:function(){
val*=2;
}
};
json.dbl();
alert(json.val+val);
}());
var test=(function(i){
return function(){
alert(i*2);
}
}(2));
test(6);
function C1(){
if(name) this.name=name;
}
function C2(){
this.name=name;
}
function C3(){
this.name=name ||'John';
}
C1.prototype.name="Tom";
C2.prototype.name='Tom';
C3.prototype.name='Tom';
alert((new C1().name)+(new C2().name)+(new C3().name));
null == undefined true
"NaN" == NaN false
5 == NaN false
NaN == NaN false
NaN != NaN true
false == 0 true
true == 1 true
true == 2 false
undefined == 0 false
null == 0 false
"5" == 5 true
typeof([]) object
typeof({}) object
typeof(null) object
typeof(undefined) undefined
typeof(NaN) number
typeof(("abcd")*5) number
typeof(("abcd")+5) string