javscript get object size 1

javscript get object size

var person={
    "first_name":"Harry",
    "last_name":"Potter",
    "age":14
};
var personSize = Object.keys(person).length; //gets number of properties (3) 

Here is what the above code is Doing:
1. We create an object called person.
2. We create a variable called personSize and set it equal to the number of properties in the person object.
3. We print the value of personSize to the console.

Similar Posts