loading
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
//hoisting variable
firstName = "kenan";

console.log("hello " + firstName);

var firstName;



//not hoisting initialized variable
console.log('hello ' + fullName);

var fullName = "kenan hancer";



//hoisting function scoped variable
function sayHello(){
  name = 'kenan';
  console.log('hello ' + name);
  var name;
}

sayHello();



//not hoisting function scoped and initialized variable
function sayHelloEnglish(){
  console.log('hello ' + name);
  var name = 'kenan';
}

sayHelloEnglish();




//not hoisting function scoped but initialized after usage
function sayHelloTurkish(){
  var name;
  console.log('merhaba ' + name);
  name = 'kenan';
}

sayHelloTurkish();




//variables declared with let keywords are block scoped not function scoped. So, let is not hoisted.
console.log('hello ' + a1);
let a1 = 'kenan';






//Function declarations over variable declarations
var double;

function double(num) {
  return (num*2);
}

console.log(typeof double); // Output: function



//Variable assignment over function declaration
var age = 22;

function age(num) {
  return (num*2);
}

console.log(typeof age); // Output: number
Babel Compiler v6.4.4 Copyright (c) 2014-2015 Sebastian McKenzie