I am using redux with react. This makes dispatch available as props in component. So when I console.log(this.props)
I see following object in log under dispatch key.
[[Scopes]]: Scopes[5]
0:Closure
1:Closure
2:Closure (createThunkMiddleware)
3:Closure
4:Global
Can someone explain what is this ?
答案 0 :(得分:10)
[[Scopes]]
是Chrome开发人员工具在C ++ here in the source内部添加和使用的私有财产。它显示函数范围内的变量,即可以从该函数访问哪些变量。
例如:
function a() {
var foo = 'foo';
var obj = {
bar: function () {
return foo;
}
};
console.log(obj);
}
a();
此处,附加到属性obj.bar
的函数在其范围内具有变量foo
,因此当我们检查[[Scopes]]
obj.bar
的问题时,我们会看到类似< / p>
[[Scopes]]: Scopes[2]
0: Closure (a)
foo: "foo"
1: Global
(all global variables)
您可以在控制台中手动检查这些属性,这可能有助于调试,但您无法使用JavaScript访问它们,并且您不应该在应用程序代码中关注它们。