in this code snippet, I could not use obj before declaration
const obj = {
value : 10,
x : obj
}
while here I could
const obj = {
func : () => console.log(obj.value),
value : 10,
}
obj.func();
How could the second compiles but the first fail?
actually, I wonder why any of them compiles since I used obj
before it was instantiated, as I understand (I may be wrong) first the right side first evaluated, and then assign the result
to the variable(obj
)