0 votes
1 view
in Web Technology by (6.8k points)

How to get length and list of keys in JavaScript?

1 Answer

0 votes
by (13k points)

You try something like this:

var obj = {

  key1: 'value1',

  key2: 'value2',

  key3: 'value3',

  key4: 'value4'

};

var keys = [];

for (var k in obj) keys.push(k);

console.log("total " + keys.length + " keys: " + keys);

Interested in full-stack development? Check out the full-stack developer course from Intellipaat. 

Related questions

0 votes
1 answer
0 votes
1 answer
asked Mar 2 in Java by sheela_singh (9.2k points)
0 votes
1 answer
0 votes
1 answer
Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...