Skip to content

Instantly share code, notes, and snippets.

function foo(a) {
var b = a*2;
function bar(c) {
console.log(a, b, c);
}
bar(b * 3);
}
foo(2); //2, 4, 12
function bar() {
var a = 10;
console.log(a, b, c);
}
function bar() {
a = 10;
console.log(a, b, c);
}
function boo() {
a = 10;
}
boo();
console.log(a);//10
function foo(a) {
var b = a*2;
function bar(c) {
console.log(a, b, c);
}
bar(b * 3);
}
foo(2); //2, 4, 12
function foo(a) {
var b = a*2;
function bar(c) {
console.log(a, b, c);
}
bar(b * 3);
}
foo(2); //2, 4, 12
function foo() {
var c = 10;
function bar() {
var c = 5;
console.log(c);//5
}
bar();
}
foo();
function foo() {
a = 2;
}
foo();
console.log(a);//2
//this code creates and adds properties to an object
var obj = {
a:1,
b:2,
c:3
};
//this code changes the property values of object "obj"
//i.e the value of "a" was initially 1
obj.a = 2;
obj.b = 3;
obj.c = 4;