Skip to content

Instantly share code, notes, and snippets.

@ytyng
Created October 10, 2017 07:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ytyng/8b9b0d18f3426d9ee1eb451cdce0e2f6 to your computer and use it in GitHub Desktop.
Save ytyng/8b9b0d18f3426d9ee1eb451cdce0e2f6 to your computer and use it in GitHub Desktop.
Adobe inDesign用。Array.indexOf が実装されてないので、作る
// Adobe inDesign 用
// Array.indexOf が実装されてないので、作る
Array.prototype.indexOf = function(item){
for(var i = 0; i<this.length; i++) {
if(this[i] === item) {
return i;
}
}
return -1;
}
Array.prototype.includes = function(item){
for(var i = 0; i<this.length; i++) {
if(this[i] === item) {
return true;
}
}
return false;
}
var a = [1,2,3];
alert("indexOf(2):" + a.indexOf(2));
alert("indexOf(4):" + a.indexOf(4));
alert("includes(2):" + a.includes(2));
alert("includes(4):" + a.includes(4));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment