admin管理员组文章数量:1292299
I got this error when I try to execute the following code, I am using Ionic3 framework:
ERROR TypeError {stack: "TypeError: Object [object Array] has no method 'in… (http://192.168.0.25:8100/build/main.js:4116:76)", message: "Object [object Array] has no method 'includes'"}
// console.log(this.events) => [7704]
// console.log(event.id_calenda) => 7653
if (this.events.includes(event.id_calendar)) {
It happens in my device with Android 4.4.4, the other one with Android 7 works good, why?
I got this error when I try to execute the following code, I am using Ionic3 framework:
ERROR TypeError {stack: "TypeError: Object [object Array] has no method 'in… (http://192.168.0.25:8100/build/main.js:4116:76)", message: "Object [object Array] has no method 'includes'"}
// console.log(this.events) => [7704]
// console.log(event.id_calenda) => 7653
if (this.events.includes(event.id_calendar)) {
It happens in my device with Android 4.4.4, the other one with Android 7 works good, why?
Share asked Feb 12, 2018 at 23:24 OttoOtto 4,2006 gold badges36 silver badges46 bronze badges 3- 2 Probably because the Browser on your old device only supports an older version of EcmaScript – Thomas Commented Feb 12, 2018 at 23:32
-
1
Agreed, the older browsers don't support
.includes
. You'll need to use a polyfill for it to work on those older browsers. – CRice Commented Feb 12, 2018 at 23:37 - 1 check out polyfill.io – Thomas Commented Feb 13, 2018 at 11:25
2 Answers
Reset to default 9I fixed it using Array.prototype.indexOf()
instead of Array.prototype.includes()
:
if (this.events.indexOf(event.id_calender) >= 0) {
Array.prototype.indexOf() documentation
Array.prototype.includes() documentation
I have the same error on Android 4.4.2, but
it's needed to use >=
operator to replace Array.prototype.includes()
method:
if (this.events.indexOf(event.id_calendar) >= 0) {
本文标签: javascriptTypescript Object object Array has no method 39includes39 with Ionic 3Stack Overflow
版权声明:本文标题:javascript - Typescript Object [object Array] has no method 'includes' with Ionic 3 - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741553025a2384990.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论