AngularJS angular.copy shallow copying.

JavaScript

// Object definitions.
function Animal() {}

Animal.prototype.foo = 'bar';

function Dog() {
    Animal.call(this);
}

Dog.prototype = new Animal();
Dog.prototype.constructor = Dog;

Dog.prototype.bar = 'baz';

var original = new Dog();
var copy = angular.copy(original);

// Test code.
console.log(copy);

console.log('%ccopy is instanceof what?', 'font-weight: bold');
console.log((copy instanceof Animal) + '[Animal]: expecting true'); // is false
console.log((copy instanceof Dog) + '[Dog]: expecting true'); // is false

console.log((copy instanceof Object) + '[Object]: expecting true');

console.log('%cIf original has entire prototype chain.', 'font-weight: bold');
console.log((Animal.prototype.isPrototypeOf(original)) + '[Animal.prototype(original)]: expecting true');
console.log((Dog.prototype.isPrototypeOf(original)) + '[Dog.prototype(original)]: expecting true');

console.log('%cIf copy has entire prototype chain.', 'font-weight: bold');
console.log((Animal.prototype.isPrototypeOf(copy)) + '[Animal.prototype(copy)]: expecting true'); // is false
console.log((Dog.prototype.isPrototypeOf(copy)) + '[Dog.prototype(copy)]: expecting true'); // is false

console.log('%cWhat\'s the prototype?', 'font-weight: bold;');
console.log('Original:');
console.log(Object.getPrototypeOf(original));
console.log('Copy:');
console.log(Object.getPrototypeOf(copy));