-
Notifications
You must be signed in to change notification settings - Fork 0
/
04-UseStrict.html
50 lines (42 loc) · 1012 Bytes
/
04-UseStrict.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>UseStrict</title>
</head>
<body>
<h1>UseStrict mode javascript</h1>
<p>
With strict mode, you can not use undeclared variables.
</p>
<h3>Example-1</h3>
<p>
"use strict";<br>
x = 3.14; // This will cause an error because x is not declared
</p>
<h3>Example-2</h3>
<p>
x = 3.14; // This will not cause an error.<br>
myFunction();<br>
function myFunction() { <br>
"use strict";
y = 3.14; // This will cause an error
}
</p>
</body>
</html>
<script>
"use strict";
x = 3; //this will cause an error
</script>
<script>
x=3.14;
myFunction();
function myFunction()
{
"use strict";
y = 3.14;
}
</script>