Created
September 13, 2023 09:29
-
-
Save rowend36/45ce1917ba5c9ddff3516273bd5a20d4 to your computer and use it in GitHub Desktop.
Javascript Execution Order For ES6 Classes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Class { | |
static { | |
console.log(1) | |
} | |
static n = console.log(2) | |
static { | |
console.log(3) | |
} | |
m = console.log(7) | |
constructor(){ | |
console.log(8) | |
} | |
} | |
class Subclass extends Class { | |
static n = console.log(4) | |
m = console.log(9) | |
constructor(){ | |
console.log(6) | |
super() | |
console.log(10) | |
} | |
} | |
console.log(5) | |
new Subclass | |
console.log(11) | |
// Output | |
// 1 | |
// 2 | |
// 3 | |
// 4 | |
// 5 | |
// 6 | |
// 7 | |
// 8 | |
// 9 | |
// 10 | |
// 11 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment