You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
let o = {
get foo() {},
set foo(x){}
};
var descriptor = Object.getOwnPropertyDescriptor(o, "foo");
descriptor.get.name; // "get foo"
descriptor.set.name; // "set foo";
The text was updated successfully, but these errors were encountered:
Last line of code types in console 'undefined'. In order to know getter's ot setter's name I found decision in MDN.
var doSomething = function doSomethingElse() {
// empty
};
var person = {
get firstName() {
return "Nicholas"
},
sayName: function() {
console.log(this.name);
}
}
console.log(doSomething.name);
// "doSomethingElse"
console.log(person.sayName.name);
// "sayName"
console.log(person.firstName.name); // "get firstName"
https://developer.mozilla.org/enUS/docs/Web/JavaScript/Reference/Global_Objects/Function/name#Function_names_for_getters_and_setters
let o = {
get foo() {},
set foo(x){}
};
var descriptor = Object.getOwnPropertyDescriptor(o, "foo");
descriptor.get.name; // "get foo"
descriptor.set.name; // "set foo";
The text was updated successfully, but these errors were encountered: