Baseline Widely available
copyWithin()
㯠TypedArray
ã¤ã³ã¹ã¿ã³ã¹ã®ã¡ã½ããã§ããã®åä»ãé
åã®ä¸é¨ãåãåä»ãé
åã®å¥ã®å ´æã«ã·ã£ãã¼ã³ãã¼ãããã®åä»ãé
åã®é·ãã夿´ããã«è¿ãã¾ãããã®ã¡ã½ãã㯠Array.prototype.copyWithin()
ã¨åãã¢ã«ã´ãªãºã ã§ãã
const uint8 = new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8]);
// Insert position, start position, end position
uint8.copyWithin(3, 1, 3);
console.log(uint8);
// Expected output: Uint8Array [1, 2, 3, 2, 3, 6, 7, 8]
æ§æ
copyWithin(target, start)
copyWithin(target, start, end)
弿°
target
並ã³ã®ã³ãã¼å
ã¨ãªãã¼ãåºç¹ã®ã¤ã³ããã¯ã¹ã§ãæ´æ°ã«å¤æããã¾ãããã㯠start
ã«ããè¦ç´ ãã³ãã¼ãããå ´æã«å¯¾å¿ããstart
ãã end
ã¾ã§ã®ãã¹ã¦ã®è¦ç´ ãå¾ç¶ã®ã¤ã³ããã¯ã¹ã«ã³ãã¼ããã¾ãã
start
ã³ãã¼å ã§ã³ãã¼ãå§ããä½ç½®ã®ã¼ãåºç¹ã®ã¤ã³ããã¯ã¹ã§ãæ´æ°ã«å¤æããã¾ãã
end
çç¥å¯
ã³ãã¼å
ã§ã³ãã¼ãçµããä½ç½®ã®ã¼ãåºç¹ã®ã¤ã³ããã¯ã¹ã§ãæ´æ°ã«å¤æããã¾ãã copyWithin()
ã¯ããã¾ã§ãã³ãã¼ãã¾ããã end
ã¯å«ã¿ã¾ããã
夿´ãããåä»ãé åã§ãã
解説詳細ã«ã¤ãã¦ã¯ã Array.prototype.copyWithin()
ãã覧ãã ããããã®ã¡ã½ããã¯æ±ç¨çã§ã¯ãªããåä»ãé
åã¤ã³ã¹ã¿ã³ã¹ã«å¯¾ãã¦ã®ã¿å¼ã³åºããã¨ãã§ãã¾ãã
const buffer = new ArrayBuffer(8);
const uint8 = new Uint8Array(buffer);
uint8.set([1, 2, 3]);
console.log(uint8); // Uint8Array [ 1, 2, 3, 0, 0, 0, 0, 0 ]
uint8.copyWithin(3, 0, 3);
console.log(uint8); // Uint8Array [ 1, 2, 3, 1, 2, 3, 0, 0 ]
仿§æ¸ ãã©ã¦ã¶ã¼ã®äºææ§ é¢é£æ
å ±
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