Read full article on the Infragistics blog "In JavaScript, Object's assign method copies source object's own enumerable properties to a target object, and returns that target object " There are two important keywords in the above sentence: Enumerable Own Before we go ahead and understand purpose of Object.assign, it is essential that we really understand these two words, enumerable properties and own properties. Let us see them one by one: A JavaScript object could have either enumerable or non-enumerable properties. However, by default when you create property on an object, it is enumerable. Enumerable means you can enumerate through those properties. Let us understand it through code. There are two properties in babycat object. By default both are enumerable, hence as the output of for..in loop, you will get both age and name printed. Now let us change default enumerable behavior of age property using Object.defineProperty method. We have changed enumerable of age property to false, so as output, you will get only color printed.
I guess you came to this post by searching similar kind of issues in any of the search engine and hope that this resolved your problem. If you find this tips useful, just drop a line below and share the link to others and who knows they might find it useful too.
Stay tuned to my blog, twitter or facebook to read more articles, tutorials, news, tips & tricks on various technology fields. Also Subscribe to our Newsletter with your Email ID to keep you updated on latest posts. We will send newsletter to your registered email address. We will not share your email address to anybody as we respect privacy.
JavaScript,Clone,cloning,copy,Javascript,object,Object.assign
Stay tuned to my blog, twitter or facebook to read more articles, tutorials, news, tips & tricks on various technology fields. Also Subscribe to our Newsletter with your Email ID to keep you updated on latest posts. We will send newsletter to your registered email address. We will not share your email address to anybody as we respect privacy.
This article is related to
JavaScript,Clone,cloning,copy,Javascript,object,Object.assign
No comments:
Post a Comment