Javascript – get size of an object

In javascript, we don’t have a method who could get the size of an object directly. But we could consider it as an array, and get the size of the array.

Method 1 :

size1 = Object.keys(object).length

Method 2 :

size2 = Object.values(object).length

Method 3 :

We could wirte a function, I will give it later

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s