ES6 basis of - copies the value of an object to another object in Object.assign ()

Object.assign () can copy the properties of an object to another object which
Define a blank object breakfast
let breakfast={}

 

Here use Object.assign () method
The first parameter is the recipient, that is to be copied to the target, and the second is a copy of the source; 
 
example:
let breakfast={}

Object.assign(
  breakfast,
  {
    drink:'beer'
  }
)
console.log(breakfast)  //{drink:'beer'}

  

 

Guess you like

Origin www.cnblogs.com/fe-cherrydlh/p/11093215.html