Globals

This next group of functions can be executed from anywhere in Angular without having to inject them. They are mainly utility functions that allow you to do things easier or do things the Angular way.

Extend

This provides a way to combine two objects:

angular.extend(srcObject, destObject)

Parameters

  • srcObject(object): The object that extends will copy the properties from
  • Destobject(object): The object that extends will copy the properties to

Return value

This returns a reference of destObject.

Description

In JavaScript, there is no in-built way to extend an object using another object. This function does just that.

Here is a simple example that will extend one object with the other's property:

var first = { first: '1' }; var second = { second: '2' ...

Get Web Developer's Reference Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.