admin管理员组

文章数量:1390609

I have an ionic app that uses the set data structure in one of it's method. When I try to run the app on my android device(Android 5.0.2,API 21), I run into this error

ReferenceError: Set is not defined
at Object.myMethod

Here is a code snippet showing the line responsible for the error

myMethod: function(userid) {


      var user = [];

      var service = this;
      var userIDs = new Set();
      var promises = [];
    ...}

I am not a javascript guru but it seems to me that it might be a problem with the android web view on my device not having a built in implementation of the Set data structure. To further confuse matters, I tested this same app on another device(HTC One M8(Android 5.0.1,API 21)) and it worked fine with no errors shown. Does anybody know how to fix this?

I have an ionic app that uses the set data structure in one of it's method. When I try to run the app on my android device(Android 5.0.2,API 21), I run into this error

ReferenceError: Set is not defined
at Object.myMethod

Here is a code snippet showing the line responsible for the error

myMethod: function(userid) {


      var user = [];

      var service = this;
      var userIDs = new Set();
      var promises = [];
    ...}

I am not a javascript guru but it seems to me that it might be a problem with the android web view on my device not having a built in implementation of the Set data structure. To further confuse matters, I tested this same app on another device(HTC One M8(Android 5.0.1,API 21)) and it worked fine with no errors shown. Does anybody know how to fix this?

Share Improve this question asked Aug 9, 2016 at 15:50 OyebisiOyebisi 7542 gold badges11 silver badges25 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 3

You should try a polyfill for those devices that does not support Set:

https://github./medikoo/es6-set

It's not the most optimal option, but you could use dictionary with boolean values...

var userIDs = {};
userID["anyUserId"] = true;

本文标签: javascriptReferenceError Set is not defined Error utilizing Set data structure in Ionic appStack Overflow