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
Add a ment  | 

2 Answers 2

Reset to default 9

I 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