File tree Expand file tree Collapse file tree 3 files changed +41
-0
lines changed
Expand file tree Collapse file tree 3 files changed +41
-0
lines changed Original file line number Diff line number Diff line change 1+ node_modules
2+ * .log
3+ .DS_Store
Original file line number Diff line number Diff line change 1+ 'use strict' ;
2+
3+ function hash ( ) {
4+ let data = { } ;
5+ let counter = 0 ;
6+ return function ( key , value ) {
7+ data [ key ] = value ;
8+ counter ++ ;
9+ console . dir ( { counter } ) ;
10+ return data ;
11+ } ;
12+ }
13+
14+ let h1 = hash ( ) ;
15+ h1 ( 'name' , 'Marcus' ) ;
16+ h1 ( 'city' , 'Roma' ) ;
17+ let obj1 = h1 ( 'born' , 121 ) ;
18+ console . dir ( { obj1 } ) ;
Original file line number Diff line number Diff line change 1+ 'use strict' ;
2+
3+ function hash ( ) {
4+ let data = { } ;
5+ Object . defineProperty ( data , 'add' , {
6+ enumerable : false ,
7+ value : function ( key , value ) {
8+ data [ key ] = value ;
9+ return data ;
10+ }
11+ } ) ;
12+ return data ;
13+ }
14+
15+ console . dir (
16+ hash ( )
17+ . add ( 'name' , 'Marcus' )
18+ . add ( 'city' , 'Roma' )
19+ . add ( 'born' , 121 )
20+ ) ;
You can’t perform that action at this time.
0 commit comments