Standard built-ins

Object.getOwnPropertyNames()

Try the free JavaScript compiler

Returns all own string keys, enumerable and non-enumerable, excluding symbols.

Formal Syntax & Structure

javascript syntaxjavascript
Object.getOwnPropertyNames(obj)

Parameters & Attributes

NameTypeDescription
objObjectTarget object.

Return Value

Array

Own string keys.

Working Example

Example Snippetjavascript
const o={};Object.defineProperty(o,"n",{value:2});console.log(Object.getOwnPropertyNames(o).join(","));
JavaScript Reference