The function Object.assign
is used to assign the values of “enumerable” and “own” properties from one or more source objects to a target object (first argument). If the properties have getters or setters, they will be invoked. This is what the word “assign” means, so it's not just copying values from an object to another.
Here is an example:
class Test {
constructor(arg) {
Object.assign(this, arg);
}
}
In fact, this is my favorite use case for this operation. The above code gives you the power to assign any properties of the newly created object in the constructor.
Remember that the function can accept multiple source objects as further arguments. This function overwrites any values that already exist in the target object.
great as always
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Thanks for the post. It's helping me to do my work.
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
i learn many thing from your post
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Es un buen post, muy interesante y nos ayuda mucho a nosotros los nuevos, pasa por mi blog y apoyame
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Good post on assigning object.
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
this is very informative blog .thanks to you for sharing..i praise
you..
Carry on
thanks for sharing
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Really helpful post
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
I like
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
nice post.. i like your post
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
thanks for the valuable post
resteemit done
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
you are great soul
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
i learn many things from your post... thanks for share...
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit