Wednesday, October 12, 2011

Starting reading Object Oriented Javascript by Stoyan Stefanov again

Starting reading Object Oriented Javascript by Stoyan Stefanov again.

I used to read this book managing between my office work and completing house hold choir.
Interestingly this time, I am being asked to complete this book by tomorrow (thats a big task) and that too as an work which I'm liking it.

This book contains conceptual treasures of javascript and everytime I read, I am starting to like it more.

Small interesting codes for all.

var a=10;
var b =20;
var c = "20";

var d,e,f,g;

d= a+b;
e= a+c;
f= b+a;
g= c+a;

console.log(d);
console.log(e);
console.log(f);
console.log(g);

Can you guess the output???
d>>> 30
e>>>  1020
f>>> 30
g>>> 2010

the value of d and f remains same whereas e and f are different. since e and f becomes string variable  from the operation  e= a+c; and g= c+a;

<< number >> + << string >> will result in string concatenation
and result type will also be << string >>.


No comments:

Post a Comment

There was an error in this gadget