有人可以解释以下代码的行为吗?
let obj = {a:1, b:2}
let i = ['a']
console.log(obj[i])
>> 1
Run Code Online (Sandbox Code Playgroud)
为什么连数组都可以用来访问对象内部的属性?附带说明,这仅适用于长度为1的数组。我曾尝试对此进行研究,但据我所知,目前还没有任何文档解释为什么它应该起作用。
我正在 Detox 上编写 e2e 测试,以测试 React Native 中的 Firebase 应用程序。看起来对firebase.auth().signInWithPhoneNumber(number)调度的调用会调度调度队列上的某些项目,但这些项目似乎从未出列,因此测试无法继续。我的预感是登录调用发出的网络请求永远无法解析。\n以下是日志:
detox[41991] INFO: [APP_STATUS] The app is busy with the following tasks:\n\xe2\x80\xa2 There are 2 work items pending on the dispatch queue: "Main Queue (<OS_dispatch_queue_main: com.apple.main-thread>)".\n\xe2\x80\xa2 Run loop "Main Run Loop" is awake.\nRun Code Online (Sandbox Code Playgroud)\n我已阅读此故障排除指南,看起来该操作是在主线程(本机)上进行的,并且问题是等待太多的问题。
\n有没有办法检查调度队列上的项目以进一步了解它们是什么?我尝试运行/usr/bin/xcrun simctl spawn <device> log stream --level debug --style compact --predicate \'process == "myapp"\'但我不明白输出。如果有用的话我可以上传日志。
我希望我可以发布一些某种类型的日志,有人可以帮助我找到调度队列中的项目的原因或为我指出正确的方向。\n我没有本机开发经验,因此设备系统日志和Objective C/Swift 代码对我来说毫无意义。\n谢谢
\n19.4.2