JavaScript Object.getOwnPropertyNames()

Definition and Usage

Object.getOwnPropertyNames() Ang method ay ibibigay ang isang array na naglalaman ng pangalan ng lahat ng property ng object.

Object.getOwnPropertyNames() Ang method ay hindi magbabago ng orihinal na object.

Related Methods:

Object.defineProperty() Add or modify properties.

Object.defineProperties() Add or modify multiple properties.

Object.getOwnPropertyNames() Return all property names of the object.

Object.getOwnPropertyDescriptor() Return the descriptors of the property.

Object.getOwnPropertyDescriptors() Return the descriptors of all properties of the object.

Instance

// Create an object
const person = {
  firstName: "Bill",
  lastName: "Gates",
  age: 50,
  eyeColor: "blue"
};
// Get all property names
let props = Object.getOwnPropertyNames(person);

Try It Yourself

Syntax

Object.getOwnPropertyNames(object)

Parameter

Parameter Description
object Mandatory. Target object.

Return Value

Type Description
Array Array na naglalaman ng pangalan ng lahat ng atributo ng object.

Browser Support

Object.getOwnPropertyNames() Ito ay katangian ng ECMAScript5 (ES5).

Simula noong Hulyo 2013, lahat ng modernong browser ay ganap na sumusuporta sa ES5 (JavaScript 2009):

Chrome Edge Firefox Safari Opera
Chrome 23 IE/Edge 11 Firefox 21 Safari 6 Opera 15
September 2012 September 2012 April 2013 July 2012 July 2013