3 dot javascript code example
Example 1: three dots in javascript
// Extracts elements in Dict
let team = {
lead: "Bob",
num2: "Rob",
num3: "Dog",
}
// team
{lead: "Bob", num2: "Rob", num3: "Dog"}
let students = {
num1: "Andy",
num4: "Ben",
...team
}
//students
{num1: "Andy", num4: "Ben", lead: "Bob", num2: "Rob", num3: "Dog"}
Example 2: 3 dots to get all object properties in JS
this.setState(prevState => {
return {foo: {...prevState.foo, a: "updated"}};
});