How to find the length of an associative array in javascript

Associative array is an array with named indexes. In Javascript, there is no concept called associative arrays. In javascript we call them as objects.

Below is an example to find the length of the object.

var employee = [];
employee['first name'] = 'Raju';
employee['name'] = 'Raghu';
employee['age'] = 28;
var length = Object.keys(employee).length;

Published by deeps blog

Programmer

Leave a comment

Design a site like this with WordPress.com
Get started