-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathfunction_expression.html
More file actions
37 lines (31 loc) · 841 Bytes
/
Copy pathfunction_expression.html
File metadata and controls
37 lines (31 loc) · 841 Bytes
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
<!DOCTYPE html>
<html>
<head>
<title>Javascript Function Expression</title>
</head>
<body>
<h2>Javascript Function Expression</h2>
<script>
// You will get type erroror calling show function
// console.log(show);
// show();
// let show = function() {
// console.log(this);
// }
// Correct method
let show1 = function() {
console.log(this);
}
show1();
var a = new show1();
console.log(a);
// showing correct method with hoisting. why calling show1 function after function expression is needed
// Hoisting method break it into two statements 1. delaration 2. expression. put expression part at top of the page
// let show1 = undefined;
// show1 = function() {
// console.log(this);
// }
// show1();
</script>
</body>
</html>