Friday, June 14, 2013

Surprise.js


A random collection of surprises after a couple of days of wandering.

>> var a = [1, 2, 3];
>> 3 in a   // returns false
 
 
>> var a = [1, 2, 3];
>> delete a[0];
>> a.length; //returns 3
 

>> var a=1; 
>> function f() {console.log(a); var a=2;}; 
>> f();  //prints 'undefined'


>> var aa = new Boolean(false);
>> !! aa; // returns true

No comments: