return keysArr; By putting it to the console I get this: This object is loaded with the fetch function: I have tried to get the attributes by using get according to the tutorials (console.log(companies[0].get("name"));) with no luck. This is the same as iterating with a for.in loop, except that a for.in loop enumerates properties in the prototype chain as well. https://stackoverflow.com/a/7010268/96100, https://stackoverflow.com/a/4456805/96100, Improving time to first byte: Q&A with Dana Lawson of Netlify, What its like to be on the Python Steering Council (Ep. Now, In this one, certainly you can notice that we are actually mapping it in each level (we have to, no other way with first map only approach. A collection of properties. ), Try below example to understand this completely. ]; (The reason you get undefined for console.log(result.id) is that strings don't have an id property.). Object.values() - JavaScript | MDN - MDN Web Docs See Also: The getAttribute () Method I can't imagine why we have to wait for ES2017 to get an Object.values() method. Do US citizens need a reason to enter the US? Warning: Modifying the prototype property of any built-in constructor is considered a bad practice and risks forward compatibility. The constructor function that created the instance object. You can enumerate through an element's attributes using forof. How to list the properties of a JavaScript object? For instance, lets create a new property in document.body: We can also modify built-in prototypes like Element.prototype and add new methods to all elements: So, DOM properties and methods behave just like those of regular JavaScript objects: In HTML, tags may have attributes. This is the easiest and purest solution in js without using any libraries or any other utilities. These get values from an object and avoid enumerating over the prototype chain. For instance, if the tag is , then the DOM object has body.id="page". It's working even for non-enumerable properties. What if we use a non-standard attribute for our purposes and later the standard introduces it and makes it do something? This example will probably make things clearer: For example, a runnable code is added here: Here's a function similar to PHP's array_values(). Object.getOwnPropertyNames() - JavaScript | MDN - MDN Web Docs Get the value of the onclick attribute of a