ecmascript-2018

What does { …obj1, obj2 } do exactly [duplicate]

心已入冬 提交于 2019-12-13 12:43:01
问题 This question already has answers here : What do these three dots in React do? (22 answers) Closed 8 months ago . Let's say we have two objects: const state = { fishes: { /* some obj data */ }, animals: { /* some obj data */ } const animals = { /* some NEW data */ } In Vuex there is a method replaceState(), which according to the documentation takes one argument and replaces the state with that object. What will be the result of the following: replaceState({ ...state, animals }) More

What makes ES6 so special?

眉间皱痕 提交于 2019-12-13 07:46:51
问题 So I've only recently started to dive head first into web development. One thing I gathered very quickly was that ES5 = old, and ES6 = shiny and new. I figured ES6 was the latest and greatest ES had to offer. But I just found out that ES6 is 3 standards behind, and that some of the features I've been using and loving aren't even a part of it—they came in later specifications. So why does everything I read make it seem like there's just ES5 and ES6? 回答1: ES6 (later rebranded as ES2015 ) simply

What does { …obj1, obj2 } do exactly [duplicate]

三世轮回 提交于 2019-12-08 21:57:27
This question already has answers here : What do these three dots in React do? (22 answers) Closed 8 months ago . Let's say we have two objects: const state = { fishes: { /* some obj data */ }, animals: { /* some obj data */ } const animals = { /* some NEW data */ } In Vuex there is a method replaceState(), which according to the documentation takes one argument and replaces the state with that object. What will be the result of the following: replaceState({ ...state, animals }) More specifically, what does { ...state, animals } do exactly? To bring some context, I took this example from the