Sharing Top Content from the Angular-sphere.

In Too Deep?

  • In use, jQuery.extend({}, originalObj) says, take my original object and make a copy into a brand new empty object.
  • Objects can have infinite levels and for that we need angular.merge() which performs a true deep copy of an object.
  • You want to modify the values to create a new Kryptonian, but you want to keep the original state of your object.
  • To do this, you can make a copy of the original object and modify the copy you would like.
  • It performs only a shallow copy of an object in which you only have a copy of top level parent properties on an object.

Read the full article, click here.


@refinedjs: “New blog post – Getting deep with objects in #AngularJS #javascript #deepcode #codeissexy #refinedjs”


Let’s say you had object { name: ”, dob: ”, planet: ‘Krypton’ }. You want to modify the values to create a new Kryptonian, but you want to keep the original state of your object. To do this, you can make a copy of the original object and modify the copy however you would like. With jQuery, we learned to copy objects using jQuery.extend(). In use, jQuery.extend({}, originalObj) says, take my original object and make a copy into a brand new empty object. If you want to preserve default values you can copy the original along with a new object that changes some of the defaults and adds new properties using jQuery.extend({}, originalObj, newObj).


In Too Deep?

Comments are closed, but trackbacks and pingbacks are open.