About 437,000 results
Open links in new tab
  1. Map - JavaScript | MDN - MDN Web Docs

    Apr 2, 2025 · The Map object holds key-value pairs and remembers the original insertion order of the keys. Any value (both objects and primitive values) may be used as either a key or a value.

  2. javascript - map function for objects (instead of arrays ... - Stack ...

    Feb 11, 2013 · You could use Object.keys and then forEach over the returned array of keys: var myObject = { 'a': 1, 'b': 2, 'c': 3 }, newObject = {}; Object.keys(myObject).forEach(function (key) { var value = myObject[key]; newObject[key] = value * value; }); Or in a more modular fashion:

  3. JavaScript Object.keys() Method - W3Schools

    The Object.keys() method returns an array with the keys of an object. The Object.keys() method does not change the original object.

  4. How to map key/value pairs of a "map" in JavaScript?

    Mar 1, 2024 · To get its properties as key/value pairs, you can use Object.entries, which you can then apply map to: Object.entries is relatively new, but easily polyfilled for older environments. Live Example: Or, using a Map, you can use its built-in entries method, which returns an iterable, passing it into Array.from and using Array.from 's mapping callback:

  5. Using Array objects as key for ES6 Map - Stack Overflow

    Understand that ES2015 Map keys are compared (almost) as if with the === operator. Two array instances, even if they contain the same values, do not ever compare as === to each other. Try this: var a = new Map(), key = ['x', 'y']; a.set(key, 1); console.log(a.get(key));

  6. Object.keys, values, entries - The Modern JavaScript Tutorial

    Jun 27, 2021 · Object.keys, values, entries. For plain objects, the following methods are available: Object.keys(obj) – returns an array of keys. Object.values(obj) – returns an array of values. Object.entries(obj) – returns an array of [key, value] pairs. Please note the distinctions (compared to map for example):

  7. JavaScript Map Object - JavaScript Tutorial

    To get the keys of a Map object, you use the keys() method. The keys() returns a new iterator object that contains the keys of elements in the map. The following example displays the username of the users in the userRoles map object.

  8. Map.prototype.keys() - JavaScript | MDN - MDN Web Docs

    Feb 11, 2025 · The keys() method of Map instances returns a new map iterator object that contains the keys for each element in this map in insertion order.

  9. JavaScript Map keys () Method: Getting Map Keys - CodeLucky

    Feb 5, 2025 · The JavaScript Map object is a powerful data structure that stores key-value pairs, where keys can be of any data type. The keys() method is an essential part of the Map API, allowing you to retrieve an iterator that yields all the keys in the map.

  10. JavaScript Map Object: Working with Maps - CodeLucky

    Feb 6, 2025 · Unlike traditional JavaScript objects, where keys are limited to strings or symbols, Map objects offer greater flexibility and control. This guide provides a comprehensive overview of the Map object, its properties, methods, and practical usage with clear examples.

  11. Some results have been removed