Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

object.keys

//Look at the other comments but heres a way I made it more simple

Object.prototype.keys=function(){return Object.keys(this);}

//you might see that im trying to make it short and comment use arrow functions.
//but arrow functions actually have diffrent abilites. see what happens.

const obj = {
foo:"bar",
bar:"foo"
}

console.log(obj.keys()); //["foo", "bar"]

Object.defineProperty(Object.prototype, "keys", { //more simpler to use
get:function(){return Object.keys(this);}
});

console.log(obj.keys); //["foo", "bar"]
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged:
ADD COMMENT
Topic
Name
2+9 =