Skip to content

Instantly share code, notes, and snippets.

@jsumners
Created September 5, 2017 14:43
Show Gist options
  • Select an option

  • Save jsumners/cfb7ba6509da7ce968f817ec89cf23b9 to your computer and use it in GitHub Desktop.

Select an option

Save jsumners/cfb7ba6509da7ce968f817ec89cf23b9 to your computer and use it in GitHub Desktop.
// https://tc39.github.io/ecma262/#sec-set-constructor
const MyList = class MyList extends Set {}
MyList.fromArray = function (aray) {
const list = new MyList()
array.forEach((a) => list.add(a)
return list
}
MyList.prototype.has = function (ele) {
let result = false
for (const i of this) {
if (i.property === ele) {
result = true
break
}
}
return result
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment