Friday, January 18, 2013

Intriguing JavaScript (for a C# developer like me)


Following creates and calls the function, straight away.
(function(message){
    alert(message);
})('hello world');


Following mean the same!
A) object1.function1(data1);
B) object1['function1'](data);

JQuery:
$ is a function name. It's not any special syntax. Rocket science $#@%^$

= = Vs = = =
True for the following
var a = 10 /*integer 10 */, b ="10" /*string 10 */;
alert(a == b);

False for the following
var a = 10 /*integer 10 */, b ="10" /*string 10 */;
alert(a === b);

Undefined Vs null 
var a; 
alert(a == null); //true
alert(a == undefined); //true

But initialization defines type of variable,
var a = 10; alert(typeof(a)); //number
var a = ''; alert(typeof(a)); //string
var a = null; alert(typeof(a)); //object
 
So
var a; alert(typeof(a)); //undefined

No comments:

Post a Comment