File tree Expand file tree Collapse file tree 7 files changed +36
-29
lines changed
Expand file tree Collapse file tree 7 files changed +36
-29
lines changed Original file line number Diff line number Diff line change 11'use strict' ;
22
33function hash ( ) {
4- let data = { } ;
4+ const data = { } ;
55 let counter = 0 ;
66 return function ( key , value ) {
77 data [ key ] = value ;
@@ -11,8 +11,8 @@ function hash() {
1111 } ;
1212}
1313
14- let h1 = hash ( ) ;
14+ const h1 = hash ( ) ;
1515h1 ( 'name' , 'Marcus' ) ;
1616h1 ( 'city' , 'Roma' ) ;
17- let obj1 = h1 ( 'born' , 121 ) ;
17+ const obj1 = h1 ( 'born' , 121 ) ;
1818console . dir ( { obj1 } ) ;
Original file line number Diff line number Diff line change 11'use strict' ;
22
33function hash ( ) {
4- let data = { } ;
4+ const data = { } ;
55 Object . defineProperty ( data , 'add' , {
66 enumerable : false ,
7- value : function ( key , value ) {
7+ value ( key , value ) {
88 data [ key ] = value ;
99 return data ;
1010 }
@@ -14,7 +14,7 @@ function hash() {
1414
1515console . dir (
1616 hash ( )
17- . add ( 'name' , 'Marcus' )
18- . add ( 'city' , 'Roma' )
19- . add ( 'born' , 121 )
17+ . add ( 'name' , 'Marcus' )
18+ . add ( 'city' , 'Roma' )
19+ . add ( 'born' , 121 )
2020) ;
Original file line number Diff line number Diff line change 22
33function add ( x ) {
44 return function ( y ) {
5- let z = x + y ;
5+ const z = x + y ;
66 console . log ( x + '+' + y + '=' + z ) ;
77 return z ;
88 } ;
Original file line number Diff line number Diff line change 22
33function add ( x ) {
44 return function ( y ) {
5- let z = x + y ;
5+ const z = x + y ;
66 console . log ( x + '+' + y + '=' + z ) ;
77 return add ( z ) ;
88 } ;
99}
1010
11- let a1 = add ( 5 ) ;
12- let a2 = a1 ( 2 ) ;
13- let a3 = a2 ( 3 ) ;
14- let a4 = a1 ( 1 ) ;
15- let a5 = a2 ( 10 ) ;
11+ const a1 = add ( 5 ) ;
12+ const a2 = a1 ( 2 ) ;
13+ const a3 = a2 ( 3 ) ;
14+ const a4 = a1 ( 1 ) ;
15+ const a5 = a2 ( 10 ) ;
1616
1717console . log ( '--------' ) ;
1818
Original file line number Diff line number Diff line change 11'use strict' ;
22
33function logger ( level ) {
4- let color = logger . colors [ level ] || logger . colors . info ;
4+ const color = logger . colors [ level ] || logger . colors . info ;
55 return function ( s ) {
6- let date = new Date ( ) . toISOString ( ) ;
6+ const date = new Date ( ) . toISOString ( ) ;
77 console . log ( color + date + '\t' + s ) ;
88 } ;
99}
@@ -14,9 +14,9 @@ logger.colors = {
1414 info : '\x1b[1;37m'
1515} ;
1616
17- let warning = logger ( 'warning' ) ;
18- let error = logger ( 'error' ) ;
19- let debug = logger ( 'debug' ) ;
17+ const warning = logger ( 'warning' ) ;
18+ const error = logger ( 'error' ) ;
19+ const debug = logger ( 'debug' ) ;
2020
2121warning ( 'Hello' ) ;
2222error ( 'World' ) ;
Original file line number Diff line number Diff line change 11'use strict' ;
22
33function add ( x ) {
4- let f = function ( y ) {
5- let z = x + y ;
4+ const f = function ( y ) {
5+ const z = x + y ;
66 console . log ( x + '+' + y + '=' + z ) ;
77 return add ( z ) ;
88 } ;
@@ -12,11 +12,9 @@ function add(x) {
1212 return f ;
1313}
1414
15- let a1 = add ( 5 ) ;
16- let a2 = a1 ( 2 ) ;
17- let a3 = a2 ( 3 ) ;
18- let a4 = a1 ( 1 ) ;
19- let a5 = a2 ( 10 ) ;
15+ const a1 = add ( 5 ) ;
16+ const a2 = a1 ( 2 ) ;
17+ const a3 = a2 ( 3 ) ;
18+ const a4 = a1 ( 1 ) ;
19+ const a5 = a2 ( 10 ) ;
2020a5 . map ( console . log ) ;
21-
22- add ( 2 ) ( 7 ) ( 1 ) . map ( console . log ) ;
Original file line number Diff line number Diff line change 1+ 'use strict' ;
2+
3+ function add ( x ) {
4+ const f = y => add ( x + y ) ;
5+ f . map = fn => fn ( x ) ;
6+ return f ;
7+ }
8+
9+ add ( 2 ) ( 7 ) ( 1 ) . map ( console . log ) ;
You can’t perform that action at this time.
0 commit comments