gpt4 book ai didi

javascript - 在 Angular 作用域和其中包含的对象中赋值

转载 作者:行者123 更新时间:2023-11-30 10:30:37 24 4
gpt4 key购买 nike

我刚刚阅读了这篇关于 JavaScript 继承和 Angular 作用域的文章: https://github.com/angular/angular.js/wiki/Understanding-Scopes

他们指的是这样一段代码:

Suppose we then do this:

childScope.aString = 'child string'

然后跟进:

Suppose we then do this:

childScope.anArray[1] = '22'
childScope.anObject.property1 = 'child prop1'

现在第一个将被添加到子作用域中,因为它在父作用域中找不到。但是,第二个是在父级中找到的,因此不会添加到子级中。

我不明白的是 aString 也出现在父作用域中,那么在这种情况下“未咨询原型(prototype)链”是怎么回事?看来所有的例子都应该可以引用父级。

最佳答案

设置属性时不引用原型(prototype)链。

在对象示例中,您将获取范围的属性(anObjectAnArray),然后设置返回对象的属性.

关于javascript - 在 Angular 作用域和其中包含的对象中赋值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17154265/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com