Created
June 13, 2022 09:44
-
-
Save 12cassie34/3ed96b8b508921473299f04ab89cc0ea to your computer and use it in GitHub Desktop.
Vue Reactivity
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const myFriendList = { | |
list: ["Pauline", "Ségoline", "Christina"], | |
get lastNewFriend() { | |
return this.list[this.list.length - 1] | |
}, | |
set addNewFriend(newFriend) { | |
this.list.push(newFriend) | |
} | |
} | |
console.log(myFriendList.lastNewFriend) // "Christina" | |
myFriendList.addNewFriend = "Rosalie" | |
console.log(myFriendList.lastNewFriend) // Rosalie |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment