Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

object spread method

this.setState(prevState => {
  let jasper = Object.assign({}, prevState.jasper);  // creating copy of state variable jasper
  jasper.name = 'someothername';                     // update the name property, assign a new value                 
  return { jasper };                                 // return new object jasper object
})
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #object #spread #method
ADD COMMENT
Topic
Name
5+4 =