File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- /*Knowledge about Object*/
1+ /* Knowledge about Object */
22"use strict" ;
3- /*How to create an empty Object ?*/
3+
4+ /* How to create an empty Object ? */
45let anObject ;
56
6- // same
7+ // same
78anObject = Object . create ( Object ) ;
9+ anObject = Object ( ) ;
810anObject = { } ;
911
1012// without prototype
11- anObject = Object . create ( null ) ;
13+ anObject = Object . create ( null ) ;
14+
15+ // assign simple
16+ anObject [ "key" ] = "value" ;
17+
18+ // assign multiple
19+ Object . assing ( anObject , {
20+ "key1" : "value1" ,
21+ "key2" : "value2" ,
22+ } ) ;
23+
24+ // get a specific value
25+ anObject [ "key" ] ;
26+
27+ // get Length
28+ Object . keys ( anObject ) . length ;
29+ Object . values ( anObject ) . length ;
30+ Object . entries ( anObject ) . length ;
31+
32+ // iterate over
33+ // keys only
34+ Object . keys ( anObject ) . forEach ( function ( key ) {
35+
36+ } ) ;
37+
38+ // values only
39+ Object . values ( anObject ) . forEach ( function ( value ) {
40+
41+ } ) ;
42+
43+ // keys and values
44+ Object . entries ( anObject ) . forEach ( function ( [ key , value ] ) {
45+
46+ } ) ;
47+
48+ // has
49+ anObject . hasOwnProperty ( "key" ) ;
50+
51+ // has safe, works even when anObject has a key "hasOwnProperty"
52+ Object . prototype . hasOwnProperty . call ( anObject , "key" ) ;
Original file line number Diff line number Diff line change @@ -24,7 +24,6 @@ s.add(6);
2424s . add ( 7 ) ;
2525
2626let l = listFromSet ( s ) ;
27- let l2 = listFromSet2 ( s ) ;
28- let l3 = listFromSet3 ( s ) ;
29-
30- console . log ( s , l , l2 , l3 ) ;
27+ let l2 = listFromSet2 ( s ) ;
28+ let l3 = listFromSet3 ( s ) ;
29+ let l4 = [ ...s ] ;
You can’t perform that action at this time.
0 commit comments