0

I'm trying to read through the code here:

http://jsbin.com/wecisumumu/1/edit?html,js,output

However, this calls

angular.extend(wrap, $delegate);

where wrap and $delegate are two functions. The angular docs say that extend is called on two objects. What does it mean to call it on two functions?

2 Answers 2

2

In javascript functions are also objects:

var foo = function() {
  console.log('hello!')
}

foo.test = 'hi!'

foo() // hello!
console.log(foo.test) // hi!
0

It means this function put those two objects together. For example:var a angular.extend({a: 1}, {b: 2}) result: {a: 1, b : 2}

params: first param is distination object, second and others are source. You can point any amount of object angular.extend(dist, sour1, sour2)

return referense on a distination object

4
  • I believe OP already knows the purpose of extend(); they are asking what is happening when you pass functions as parameters instead of plain objects.
    – sp00m
    Commented Nov 6, 2015 at 13:45
  • function is object, isn't it? It's obviously.
    – Errorpro
    Commented Nov 6, 2015 at 13:48
  • I don't think it's that obvious, depending on the programming background you have ;)
    – sp00m
    Commented Nov 6, 2015 at 13:50
  • 1
    It's true. Anyway i hope my answer once will help someone)
    – Errorpro
    Commented Nov 6, 2015 at 13:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.