There is a key-value array.

var enumKeys = {1:3,2:20,3:10,4:10}; 

In the cycle I compare the values ​​of the elements. You must specify the first and last (i.e., the size of enumKeys) elements.

 for (var i = 2; i < enumKeys.lenght; i++) { // ... } 

enumKeys.lenght gives the value undefined How do I know the size of enumKeys.lenght ?

    1 answer 1

     var enumKeys = {1:3,2:20,3:10,4:10}; console.log( Object.keys( enumKeys ).length ); Object.keys( enumKeys ).forEach( propName => console.log( enumKeys[ propName ] ) ); 

    • Thank! Good answer! - CodeGust