File tree Expand file tree Collapse file tree 1 file changed +25
-6
lines changed Expand file tree Collapse file tree 1 file changed +25
-6
lines changed Original file line number Diff line number Diff line change 2
2
* Arrow functions have shorter syntax that function expression.
3
3
* These functions also lexically bind `this` value and are always anonymous.
4
4
*/
5
-
6
- var foo = [ "Hello" , "World" ] ;
5
+
6
+ let foo = [ "Hello" , "World" ] ;
7
7
8
8
//single arguments do not require parenthesis or curly braces.
9
- var bar = foo . map ( x => x . length ) ;
9
+ //The return statement is implicit
10
+ let bar = foo . map ( x => x . length ) ;
11
+
12
+ // ES5
13
+ var bar = foo . map ( function ( x ) { return x . length ; } ) ;
10
14
11
15
//multiline functions require curly braces
12
16
//no arguments expect parenthesis
13
- var foobar = ( ) => {
14
- console . log ( "Hello World" )
15
- }
17
+ let foobar = ( ) => {
18
+ console . log ( "Hello" ) ;
19
+ console . log ( "World" ) ;
20
+ } ;
21
+
22
+ // ES5
23
+ var foobar = function ( ) {
24
+ console . log ( "Hello" ) ;
25
+ console . log ( "World" ) ;
26
+ }
27
+
28
+ //Returning onbject literal. Requires Brackets.
29
+ let quux = ( ) => ( { "myProp" : 123 } ) ;
30
+
31
+ //ES5
32
+ var quux = function ( ) {
33
+ return { "myProp" : 123 } ;
34
+ } ;
You can’t perform that action at this time.
0 commit comments