ES5
é åã®éè¤ããå¤ãåé¤ãããæã®ã¡ã¢ã filterã§ã«ã¼ãããindexOfã§å¤ã®éè¤ããã§ãã¯ãããã¿ã¼ã³ array.indefOf(value)ãvalueèªèº«ã®ã¤ã³ããã¯ã¹ã¨ç°ãªãå ´åã¯æ¢ã«é åå ã«åãå¤ãããã¨ããå¤å® var arr = [0, 1, 2, 3, 4.1, true, false, 1, "2",â¦
1. å¤ã®å·®åããã§ã㯠2. å¤ã¨ã¤ã³ããã¯ã¹ã§ãã§ã㯠2-1. æ°æ§ã®æ¯è¼ã®ããã«ãé åAã¨é åBãæ¯ã¹é åAããå¤åãã¦ãããã®ãè¿ã 2-2. ãäºãã®é åã§ç°ãªã£ã¦ãããã®ãè¿ã
javascriptã®é¢æ°ã¨thisã¨ã®é¢ä¿ã®ã¡ã¢ã®ç¶ãã§ãã é¢æ°ã®thisã決ãããã¨ãã§ããcall()ã¨apply()ã§å®è¡ãããé¢æ°ãFunction.prototype.bindãã¢ãã¼é¢æ°ã§thisã決ãããã¦ãããã®ã ã£ãå ´åã©ããªãã®ãæ°ã«ãªã£ãã®ã§èª¿ã¹ã¦ã¿ã¾ããã call 㨠applyâ¦
EX: é åã«å«ã¾ããæ°ãå ¨ã¦0 <= N <= 255 ãã©ãã調ã¹ãã 次ã®ãã¼ã¿ããæ¡ä»¶ã«ãããããé åã ããåãåºãã // 調ã¹ãé åã®å ¥ã£ããã¼ã¿ var data = [ [ 217, 0, 0, 0 ], [ 169, 254, 0, 1 ], [ 0, 0, 0, 256 ], [ 1, 0, -1, 255 ], [ '', 0, 0, 0 ]â¦
ä¾ ãªãã¸ã§ã¯ãå ã®é¢æ°ã§setTimeoutã使ã£ã¦ãã®ä¸ã§ããªãã¸ã§ã¯ãèªèº«ãthisã¨ãã¦ä½¿ããããããªå ´å var obj = { name: 'obj', func: function() { console.log(this); // => Object setTimeout(function() { console.log(this, this.name); // => Winâ¦
ããå æ¸é åã®ã«ã¼ãã«ã¯Array#forEachã使ã£ã¦ããããã¨æã£ã¦ãã¾ãã é常ã®é åã§ããã°ä¸è¨ã®ãããªæãã var array = ['æ', 'é¿', 'é·', 'é»']; array.forEach(function(val, i) { console.log(i, elmval; }); /* â åºå 0 "æ" 1 "é¿" 2 "é·" 3 "â¦