Lijin Durairaj
Lijin Durairaj

Reputation: 5222

Understanding Hierarchy of the $scope in AngularJS?

When I create a object and navigate through the _proto__ property of it I get to know that it has been inherited from Object

enter image description here

Now when I create a new object and inherit the obj object, then I get the inheritance structure like this enter image description here

Here i can understand that the object obj1 is being inherited from the object obj and the object obj is being inherited from the object Object, which is the global object.

Now my question is, when i debug in my console i get both obj and obj1 as Object but the when i debug the $scope of angularJS i get something like this

enter image description here

Why is the $scope returning b instead of Object which can be seen in all the two images above, what is so different in angularJS, am i missing something.

UPDATE 1

when I make a object of the constructor in javascript I get the function name in the constructor as shown in the image below

enter image description here

But in the case of the $scope i see no constructor function, why is that? am i missing something, please let me know

Upvotes: 4

Views: 185

Answers (2)

Max Koretskyi
Max Koretskyi

Reputation: 105439

When you inspect an object in console, it is referenced by this object's class name, for example:

function Scope() {}
var s = new Scope();

enter image description here

In your case, instead of function Scope() {}, in the minified version the code looks like this function b() {} and new b() is used instead of new Scope()

Upvotes: 1

Estus Flask
Estus Flask

Reputation: 222309

This is because you're debugging minified application.

$scope is an instance of internal Scope or ChildScope class.

In minified Angular bundle the class is called something like b.

Upvotes: 2

Related Questions