-
Notifications
You must be signed in to change notification settings - Fork 4k
Description
Hello there,
It is written in class field section(https://javascript.info/class):
"Technically, they are processed after the constructor has done it’s job, and we can use for them complex expressions and function calls:
`class User {
name = prompt("Name, please?", "John");
}
let user = new User();
alert(user.name); // John`
"
I've checked it using this code.
`class User {
name = prompt("Name, please?", "John");
constructor() {
alert("I was here later!");
}
}
let user = new User();
alert(user.name); // John`
And as I had expected "prompt" was called before "alert", because I think "Class fields are processed before constructor."
I've been learning from your awesome tutorials since some days and they are really awesome.
I want to thank you for these awesome articles!!!