I have a very weird issue happening in iOS9 beta 5 - arrays seem to be empty even when elements have been added.
Sounds crazy but here's what it looks like in Safari iOS9 - this is just on the google homepage, no plugins - just vanilla webkit/javascript:
Whereas on Safari desktop, I see the correct behaviour:
Is anyone else having this issue?
Here's the code to reproduce:
myArray = ['cat', 'dog', 'fish']
console.log(myArray.length)
console.log(myArray)
console.log(myArray.slice(0,1))
console.log(myArray.indexOf('fish'))
Thanks!
It looks like you are using Safari 8 to inspect iOS 9. You should be using Safari 9 or later to inspect iOS 9. Safari 9 is available on El Capitan, Yosemite, and Mavericks.
You may also use a WebKit Nightly on Yosemite and Mavericks to get equivalent behavior.
这似乎是由toString
的实现引起的, console.log
正在调用,而不是一个空数组。
The problem is with the console. You can see the value to debug using alert if you need to.
eg: alert(['cat', 'dog'])
. It will pop up the result you need.
I had a similar issue when I was using replaceAll
method. It does not have support in ios/safari 12. If you are facing this probably you can have issues with some functions like the replaceAll. For my case I had to use a polyfill .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.