Baseline Widely available
fill()
㯠TypedArray
ã¤ã³ã¹ã¿ã³ã¹ã®ã¡ã½ããã§ãåä»ãé
åã®ããç¯å²ã®ã¤ã³ããã¯ã¹ã«ãããã¹ã¦ã®è¦ç´ ãåºå®å¤ã§åãã¾ããããã¯å¤æ´ãããåä»ãé
åãè¿ãã¾ãããã®ã¡ã½ããã®ã¢ã«ã´ãªãºã 㯠Array.prototype.fill()
ã¨åãã§ãã
const uint8 = new Uint8Array([0, 0, 0, 0]);
// Value, start position, end position
uint8.fill(4, 1, 3);
console.log(uint8);
// Expected output: Uint8Array [0, 4, 4, 0]
æ§æ
fill(value)
fill(value, start)
fill(value, start, end)
弿°
value
åä»ãé åãåããå¤ã§ãã
start
çç¥å¯
åã¾ãç¯å²ã®éå§ç¹ã表ãã¼ãåºç¹ã®ã¤ã³ããã¯ã¹ã§ãæ´æ°ã«å¤æããã¾ãã
end
çç¥å¯
åã¾ãç¯å²ã®çµäºç¹ã表ãã¼ãåºç¹ã®ã¤ã³ããã¯ã¹ã§ãæ´æ°ã«å¤æããã¾ãã fill()
㯠end
ã®æåã¾ã§ãåãã¾ãã
夿´ãããé åã§ãã
解説詳細ã«ã¤ãã¦ã¯ã Array.prototype.fill()
ãã覧ãã ããããã®ã¡ã½ããã¯æ±ç¨çã§ã¯ãªããåä»ãé
åã¤ã³ã¹ã¿ã³ã¹ã«å¯¾ãã¦ã®ã¿å¼ã³åºããã¨ãã§ãã¾ãã
new Uint8Array([1, 2, 3]).fill(4); // Uint8Array [4, 4, 4]
new Uint8Array([1, 2, 3]).fill(4, 1); // Uint8Array [1, 4, 4]
new Uint8Array([1, 2, 3]).fill(4, 1, 2); // Uint8Array [1, 4, 3]
new Uint8Array([1, 2, 3]).fill(4, 1, 1); // Uint8Array [1, 2, 3]
new Uint8Array([1, 2, 3]).fill(4, -3, -2); // Uint8Array [4, 2, 3]
仿§æ¸ ãã©ã¦ã¶ã¼ã®äºææ§ é¢é£æ
å ±
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4