# `copy` ( global in module `ng` )

## Description

Creates a deep copy of `source` , which should be an object or an array.

- If no destination is supplied, a copy of the object or array is created.
- If a destination is provided, all of its elements (for array) or properties (for objects) are deleted and then all elements/properties from the source are copied to it.
- If `source` is not an object or array, `source` is returned.

Note: this function is used to augment the Object type in Angular expressions. See `ng.$filter` for more information about Angular arrays.

## Usage

    angular.copy(source[, destination]);

### Parameters

- `source – {*} –`

  The source that will be used to make a copy. Can be any type, including primitives, `null` , and `undefined` .

- `destination(optional) – {(Object|Array)=} –`

  Destination into which the source is copied. If provided, must be of the same type as `source` .

### Returns

`{*}` –

The copy or updated `destination` , if `destination` was specified.