Object.getOwnPropertyNames() vs. Object.keys()

Object.getOwnPropertyNames() vs. Object.keys()

getOwnPropertyNames(a) returns all own properties of the object a . Object. keys(a) returns all enumerable own properties. It means that if you define your object properties without making some of them enumerable: false these two methods will give you the same result.

Quick Intro to Object.getOwnPropertyNames()

The Object.getOwnPropertyNames() method returns an array of all properties (including non-enumerable property) found directly in a given object




Object.getOwnPropertyNames() returns all keys of the object

[ '0', '1', '2' ]

Quick Intro to Object.keys()

The Object.keys() method returns an array of a given object’s own enumerable property names, iterated in the same order that a normal loop would




Object.keys returns the same output as Object.getOwnPropertyNames() because every elements in the obj is enumerable

[ '0', '1', '2' ]

Finally, Object.getOwnPropertyNames() vs. Object.keys()

Object.getOwnPropertyNames(obj) returns all the properties of the object. Object.keys(obj) returns _all enumerable properties. _They provide the same result unless you set enumerable: false to any property

javascript coding technology web-development es6

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

Why Web Development is Important for your Business

With the rapid development in technology, the old ways to do business have changed completely. A lot more advanced and developed ways are ...

Important Reasons to Hire a Professional Web Development Company

    You name the business and I will tell you how web development can help you promote your business. If it is a startup or you seeking some...

Hire Dedicated eCommerce Web Developers | Top eCommerce Web Designers

Build your eCommerce project by hiring our expert eCommerce Website developers. Our Dedicated Web Designers develop powerful & robust website in a short span of time.

How long does it take to develop/build an app?

This article covers A-Z about the mobile and web app development process and answers your question on how long does it take to develop/build an app.

Progressive Web App Development

Hire Full Stack Developer from HireFullStackDeveloperIndia.com to build user-centric & robust Progress Web App Development Solutions in India.