 
  Data Structure Data Structure
 Networking Networking
 RDBMS RDBMS
 Operating System Operating System
 Java Java
 MS Excel MS Excel
 iOS iOS
 HTML HTML
 CSS CSS
 Android Android
 Python Python
 C Programming C Programming
 C++ C++
 C# C#
 MongoDB MongoDB
 MySQL MySQL
 Javascript Javascript
 PHP PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Length of a JavaScript associative array?
You can use the length property from JavaScript to get the length. Let’s create an Associative array −
var details = new Array(); details["Name"] = "John"; details["Age"] = 21; details["CountryName"] = "US"; details["SubjectName"] = "JavaScript";
Let us now get the length of the associative array −
Example
var details = new Array(); details["Name"] = "John"; details["Age"] = 21; details["CountryName"] = "US"; details["SubjectName"] = "JavaScript"; console.log("The length=="+Object.keys(details).length); To run the above program, you need to use the following command −
node fileName.js.
Here, my file name is demo.js.
Output
This will produce the following output −
PS C:\Users\Amit\JavaScript-code> node demo.js The length==4
Advertisements
 