Rest Operator for Objects

object,tipjs,es6

Now we can use rest on the properties of an Object. It allows us to explicitly extract certain named variables, and assign any uncalled variables into a catchall Object.

const options = {
  enabled: true,
  text: 'Hello',
  color: 'red'
}
const { enabled, ...others } = options
console.log(enabled) // true
console.log(others)  // { text: 'Hello', color: 'red' }

Có thể bạn đã miss một số snippets code

Extend Object javascript

Extend Object javascript

Converting Object to an Array

Converting Object to an Array

Calculate the number of difference days between two dates

Calculate the number of difference days between two dates

Spread Operator for Objects

Using the spread operator during an Object declaration will assign the properties of the referenced Object to the new Object.

Rest Operator for Objects

Now we can use rest on the properties of an Object. It allows us to explicitly extract certain named variables, and assign any uncalled variables into a catchall Object.