The Javascript Object getOwnPropertyNames() method retrieves an array of all direct properties of the object. It will exclude non-enumerable properties which use symbols.
Syntax:
Object.getOwnPropertyNames(object)
Parameters:
object: It represents the object whose all direct properties have to be fetched.
Return:
An array of all direct properties of the object.
Example:
<!DOCTYPE html>
<html>
<body>
<script>
const obj = {alpha: 10, beta: 20, gamma: 30};
document.write(Object.getOwnPropertyNames(obj));
</script>
</body>
</html>