QuizNot attempted
Proxy vs defineProperty
1–4 to choose, Enter to submit
Show answer & explanation
Correct answer:
- Vue 3 wraps objects in a Proxy, whose traps see operations on ANY key; Vue 2 used
Object.definePropertyper existing key
- A Proxy's traps (
get,set,has,deleteProperty) see operations on ANY key of the wrapped object, including keys added later - Vue 2 used
Object.definePropertygetters/setters per key that existed at setup, so new keys neededVue.set. - Not polling: Vue never polls.
- Not getters on Object.prototype: that would affect every object and still miss own new keys.
- Not freezing: frozen objects can't be reactive at all.