Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mistake in chapter "Special Cases of the name Property"? #458

Open
alexwertand opened this issue Jan 13, 2021 · 1 comment
Open

Mistake in chapter "Special Cases of the name Property"? #458

alexwertand opened this issue Jan 13, 2021 · 1 comment

Comments

@alexwertand
Copy link

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";

@nzakas
Copy link
Owner

nzakas commented Jan 19, 2021

Yeah, looks like a mistake. Thanks for the report.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants
@nzakas @alexwertand and others