Skip to content

Instantly share code, notes, and snippets.

View SharanGoharKhan's full-sized avatar
👋

Sharan SharanGoharKhan

👋
View GitHub Profile
@SharanGoharKhan
SharanGoharKhan / this2.js
Last active October 24, 2018 20:12
Example 2 of this
obj_a = {
a: 'apple',
one: function() {
console.log(this)
two()
function two() {
console.log(this)
}
}
}
@SharanGoharKhan
SharanGoharKhan / this1.js
Created October 24, 2018 19:55
Example 1 of this
console.log(this)
function one() {
console.log(this)
}
obj_a = {
a: 'apple',
one: function() {
console.log(this)
}
}
@SharanGoharKhan
SharanGoharKhan / scoping2.js
Created October 24, 2018 14:39
Scoping example 2
one()
function one() {
var a = 'apple'
function third() {
var c = 'cat'
console.log(b)
}
two()
function two() {
var b = 'ball'
@SharanGoharKhan
SharanGoharKhan / scoping1.js
Created October 24, 2018 14:25
Scoping example 1
var a = 'apple'
one()
function one() {
var b = 'ball'
two()
function two() {
var c = 'cat'
console.log(a+b+c)
}
}
@SharanGoharKhan
SharanGoharKhan / hoisting5.js
Created October 24, 2018 14:11
Example of hoisting 5
var a = 23
function something() {
var a = 62
console.log(a)
}
something()
@SharanGoharKhan
SharanGoharKhan / hoisting4.js
Created October 24, 2018 14:06
Example of hoisting 4
console.log(a)
// var a = 23
@SharanGoharKhan
SharanGoharKhan / hoisting3.js
Created October 24, 2018 14:02
Example of hoisting 3
console.log(a)
var a = 23
console.log(a)
@SharanGoharKhan
SharanGoharKhan / hoisting2.js
Created October 24, 2018 13:58
Example 2 of hoisting
testHoisting()
var testHoisting = function() {
console.log('function is not hoisted')
}
@SharanGoharKhan
SharanGoharKhan / hoisting1.js
Created October 24, 2018 13:50
Example of hoisting example 1
testHoisting()
function testHoisting() {
console.log('function is hoisted')
}
@SharanGoharKhan
SharanGoharKhan / ECS.js
Created October 24, 2018 12:43
Execution Context Stack
var a = 'apple'
one()
function one() {
var b = 'ball'
var c = a + b
two()
}
function two() {
var d = 'dog'
var e = a + d