angular/angular.js — pull request #5063 by gentooboontoo (2013-11-21 08:57:30+00:00)
Title: Preserve prototype chaining when copying object

So far, angular.copy was copying all properties including those from
prototype chain and was losing the whole prototype chain (except for Date,
Regexp, and Array).

Deep copy should exclude properties from the prototype chain because it
is useless to do so. When modified, properties from prototype chain are
overwritten on the object itself and will be deeply copied then.

Moreover, preserving prototype chain allows instanceof operator to be
consistent between the source object and the copy.
Before this change,

var Foo = function() {};
var foo = new Foo();
var fooCopy = angular.copy(foo);
foo instanceof Foo; // => true
fooCopy instanceof Foo; // => false

Now,

foo instanceof Foo; // => true
fooCopy instanceof Foo; // => true

The new behaviour is useful when using $http transformResponse. When
receiving JSON data, we could transform it and instantiate real object
"types" from it. The transformed response is always copied by Angular.
The old behaviour was losing the whole prototype chain and broke all
"types" from third-party libraries depending on instanceof.

This PR is somewhat related to issues #3767 and #1427.

It could need some polyfills for <=IE8 so IE compatibility page at http://docs.angularjs.org/guide/ie would need some updates.