File tree 1 file changed +47
-3
lines changed
1 file changed +47
-3
lines changed Original file line number Diff line number Diff line change 1
- /**
2
- * Created by loiane on 1/10/16.
3
- */
1
+ //******* EcmaScript 6: let and const keywords
2
+ // EcmaScript 6 Constants
3
+ const PI = 3.141593 ;
4
+ //PI = 3.0; //throws error
5
+ console . log ( PI ) ;
6
+
7
+ //******* EcmaScript 6: let is the new var
8
+ var framework = 'Angular' ;
9
+ var framework = 'React' ;
10
+ console . log ( framework ) ;
11
+
12
+ let language = 'JavaScript!' ;
13
+ //let language = 'Ruby!'; //throws error
14
+ console . log ( language ) ;
15
+
16
+ //******* EcmaScript 6: variables scope
17
+ let movie = 'Lord of the Rings' ;
18
+ //var movie = 'Batman v Superman'; //throws error, variable movie already declared
19
+
20
+ function starWarsFan ( ) {
21
+ let movie = 'Star Wars' ;
22
+ return movie ;
23
+ }
24
+
25
+ function marvelFan ( ) {
26
+ movie = 'The Avengers' ;
27
+ return movie ;
28
+ }
29
+
30
+ function blizzardFan ( ) {
31
+ let isFan = true ;
32
+ let phrase = 'Warcraft' ;
33
+ console . log ( 'Before if: ' + phrase ) ;
34
+ if ( isFan ) {
35
+ let phrase = 'initial text' ;
36
+ phrase = 'For the Horde!' ;
37
+ console . log ( 'Inside if: ' + phrase ) ;
38
+ }
39
+ phrase = 'For the Alliance!' ;
40
+ console . log ( 'After if: ' + phrase ) ;
41
+ }
42
+
43
+ console . log ( movie ) ;
44
+ console . log ( starWarsFan ( ) ) ;
45
+ console . log ( marvelFan ( ) ) ;
46
+ console . log ( movie ) ;
47
+ blizzardFan ( ) ;
You can’t perform that action at this time.
0 commit comments