简体   繁体   中英

Array comparison working in Chrome but not with Chrome IPAD

I am using new_array.filter(val => !old_array.includes(val)); method to compare two array. It works fine in Chrome but not with chrome in IOS. Seems like and issue in => operator. Unfortunately debug mode is not available in IPAD which I am having. Is there any alternate for this.

Sathya

Yes. The alternative is not to use arrow functions (at least, not in the deployed version), which are a fairly new feature (although I'm very surprised to hear that Chrome for iOS doesn't support them; Chrome's underlying JavaScript engine has supported them for a long time).

To do that, you have two options:

  1. Transpile with a tool like Babel before you create the deployed version. That way you can happily use arrow functions and many (though not all) other features of ES2015 and after without worrying about support on older browsers.

  2. Or to just address that one specific thing, use a function function:

     new_array.filter(function(val) { return !old_array.includes(val); }); 

    You're not using this or super or similar that you need to close over in the callback, so it doesn't have to be an arrow function.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM