In JavaScript, what code executes at runtime and what code executes at parsetime?

后端 未结 5 2072
春和景丽
春和景丽 2020-12-12 16:13

With objects especially, I don\'t understand what parts of the object run before initialization, what runs at initialization and what runs sometime after.

EDIT: It s

5条回答
  •  旧时难觅i
    2020-12-12 16:36

    Unlike C++, it is not possible to run logic in the Javascript parser.

    I suspect that you're asking which code runs immediately and which code runs when you create each object instance.

    The answer is that any code in a function that you call will only run when you call the function, whereas any code outside of a function will run immediately.

提交回复
热议问题