Deep Copy of Object in AngularJS

AngularJS function "copy" creates a deep copy of source and source should be an object or an array. Source can be any type including null, undefined or any primitives type and destination type must be same as source.
 
Syntax:

angular.copy(source, [destination])
 
Some special Note:
  • Destination is optional field. If it is not supplied, a copy of the object or array is created.

  • If Destination is supplied, angular will remove all the element of array or properties of object and copied all elements/properties from the source.

  • If source and destination is identical, angular will throw the exception.

  • If source is not array or object or null or undefined, source will be return.
Next Recommended Reading Ternary Operator Use In AngularJS