EN
JavaScript - get list of associative array keys
0
points
In this article, we would like to show you how to get the list of associative array keys using JavaScript.
Practical example
In this example, we use keys() method to get the list of associative array keys.
// ONLINE-RUNNER:browser;
var dictionary = {
key1: [1, 2, 3],
key2: [4, 5, 6]
};
var keys = Object.keys(dictionary); // gets the keys
console.log(keys); // [ 'key1', 'key2' ]