var obj = {
key1: 'value1',
key2: 'value2',
key3: 'value3',
key4: 'value4'
}
var keys = Object.keys(obj);
console.log('obj contains ' + keys.length + ' keys: '+ keys);
It’s supported on most major browsers now.
More Related Contents:
- Write tags in HTML and print
- JavaScript – Generating combinations from n arrays with m elements [duplicate]
- Babel file is copied without being transformed
- What’s the best way to make a d3.js visualisation layout responsive?
- Image resizing client-side with JavaScript before upload to the server
- Difference between Node object and Element object?
- Calculating Page Load Time In JavaScript
- HTML5 dragleave fired when hovering a child element
- What’s wrong with var x = new Array();
- Uncaught DOMException: Blocked a frame with origin “http://localhost:8080” from accessing a cross-origin frame while listing the iframes in page
- Angularjs ui-router not reaching child controller
- `npm build` doesn’t run the script named “build” in package.json
- Javascript – No ‘Access-Control-Allow-Origin’ header is present on the requested resource
- Open link in iframe [closed]
- ES6 destructuring object assignment function parameter default value
- Load event not fired on Safari when reloading page
- Multiple Select limit number of selection
- Flex items not shrinking when window gets smaller [duplicate]
- Compare 2 JSON objects [duplicate]
- How to force a functional React component to render?
- stack and heap in V8 ( JavaScript)
- Dynamic deep setting for a JavaScript object [duplicate]
- Is there any limitation on JavaScript Max Blob size
- Using a Set data structure in React’s state
- Why is it impossible to change constructor function from prototype?
- stop dragging after a limit has reached
- Equivalent to componentDidUpdate using React hooks
- JQuery issue “TypeError: $.getJSON is not a function”
- React – Dynamically Import Components
- How to use LUT with JavaScript?