Skip to content

Instantly share code, notes, and snippets.

@rowend36
Created September 13, 2023 09:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rowend36/45ce1917ba5c9ddff3516273bd5a20d4 to your computer and use it in GitHub Desktop.
Save rowend36/45ce1917ba5c9ddff3516273bd5a20d4 to your computer and use it in GitHub Desktop.
Javascript Execution Order For ES6 Classes
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