Welcome
Hello there ! Welcome to Interaction Cloud, a place to interact, share and enrich your knowledge on interesting topics in Design Patterns, User Interface Design, Gaming, etc. . I'm a graduate student at North Carolina State university pursuing my Master's degree in computer science. As a student I'm always interested in discovering and sharing information with everyone and hence I started this blog. I am front end designer by passion and a technology enthusiast. With this blog I plan to provide exposure to technologies, user interface design standards and much more. Hope you folks find it resourceful and useful.
Don't forget to visit my site for more information -
InteractionBeats
// a global-scoped variable
ReplyDeletevar a=1;
// global scope
function one(){
alert(a);
}
// Local scope
function two(a){
alert(a);
}
// Local scope
function three(){
var a = 3;
alert(a);
}
// Intermediate:
Is there a block scope in javascript ? - No
function four(){
if(true){
var a=4;
}
alert(a); // alerts '4', not the global value of '1'
}
// Intermediate: Closure - Object properties
function Five(){
this.a = 5;
}
// Advanced: closure
var six = function(){
var foo = 6;
return function(){
// javascript - "closure" means I have access to foo in here,
// [ to be updated ]
alert(foo);
}
}()
// Advanced: Prototype scope resolution
function Seven(){
this.a = 7;
}
// [object].prototype.property loses to [object].property in the scope chain
Seven.prototype.a = -1; // Will not get reached, because a is set in the constructor above.
Seven.prototype.b = 8; // Will get reached, even though b is not set in the constructor.
o/p
one(); 1
two(2); 2
three(); 3
four(); 4
alert(new Five().a); 5
six(); 6
alert(new Seven().a); 7
alert(new Seven().b); 8