Created
January 15, 2019 03:38
-
-
Save msaxena25/ab077bfd6fd6497d0cde480421fed2d3 to your computer and use it in GitHub Desktop.
JavaScript Hoisting Console Input Output Questions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function emp() { | |
console.log('111'); | |
} | |
emp(); | |
function emp() { | |
console.log('2'); | |
} | |
Output > 2 | |
var emp = function() { | |
console.log('1'); | |
} | |
emp(); | |
function emp() { | |
console.log('2'); | |
} | |
emp(); | |
output > | |
1 | |
1 | |
var x = 5; | |
console.log(x); | |
var x; | |
output > 5 | |
var y = 10; | |
var y; | |
console.log(y); | |
output > 10 | |
var y = 10; | |
var y = 12; | |
console.log(y); | |
output > 12 | |
var z = 21; | |
let z; | |
console.log(z); | |
output > Identifier 'z' has already been declared | |
let y = 12; | |
console.log(y); | |
var y = 11; | |
output > Identifier 'y' has already been declared | |
var a = 5; | |
console.log(a); | |
var a = 7; | |
console.log(a); | |
output > | |
5 | |
7 | |
console.log(y); | |
y = 15; | |
output > ReferenceError: y is not defined | |
var x = 1; | |
console.log(x, y); | |
var y; | |
Output > 1 undefined | |
var x = 1; | |
console.log(x, y); | |
var y; | |
delete x; | |
delete y; | |
console.log(x, y); | |
output > will be same for both : 1 undefined | |
x = 1; | |
console.log(x, y); | |
var y; | |
delete x; | |
delete y; | |
console.log(x, y); | |
output > | |
1 | |
ReferenceError: x is not defined | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment