Skip to content

Commit 3975bee

Browse files
committed
Add option questions
1 parent e3b9393 commit 3975bee

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,8 @@ List of 300 VueJS Interview Questions
222222
|213| [What is Lazy loading translations?](#what-is-lazy-loading-translations)|
223223
|214| [What is the main difference between method and computed property?](#what-is-the-main-difference-between-method-and-computed-property)|
224224
|215| [What is vuetify?](#what-is-vuetify)|
225+
|216| [How do you watch for nested data changes?](#how-do-you-watch-for-nested-data-changes)|
226+
|217| [How to trigger watchers on initialization?](#how-to-trigger-watchers-on-initialization)|
225227

226228
1. ### What is VueJS?
227229
**Vue.js** is an open-source, progressive Javascript framework for building user interfaces that aim to be incrementally adoptable. The core library of VueJS is focused on the `view layer` only, and is easy to pick up and integrate with other libraries or existing projects.
@@ -3916,5 +3918,27 @@ List of 300 VueJS Interview Questions
39163918

39173919
Vue.use(Vuetify) // Add Vuetify as a plugin
39183920
```
3921+
216. ### How do you watch for nested data changes?
3922+
You can use deep watcher by setting `deep: true` in the options object. This option enables us to detect nested value changes inside Objects.
3923+
```javascript
3924+
vm.$watch('someObject', callback, {
3925+
deep: true
3926+
})
3927+
vm.someObject.nestedValue = 123
3928+
// callback is fired
3929+
```
3930+
**Note:** This is not required to listen for Array mutations.
39193931
3932+
217. ### How to trigger watchers on initialization?
3933+
You can use `immediate: true` option in order to trigger watchers when the vue instance (or component) is being created. i.e This option will trigger the callback immediately with the current value of the expression.
3934+
```javascript
3935+
watch: {
3936+
test: {
3937+
immediate: true,
3938+
handler(newVal, oldVal) {
3939+
console.log(newVal, oldVal)
3940+
},
3941+
},
3942+
},
3943+
```
39203944

0 commit comments

Comments
 (0)