SYNCERのロゴ
アイキャッチ画像

TypedArray.prototype.copyWithin() - 配列の一部分を別部分にコピーする

TypedArray.prototype.copyWithin()は、配列の一部分をコピーして、そのまま別部分に上書きするメソッドです。返り値を得られますが、元の配列も変更されます。

概要

名前
copyWithin
所属
TypedArray.prototype
仕様書
https://tc39.github.io/ecma262/#sec-%typedarray%.prototype.copywithin

説明

%TypedArray%.prototype.copyWithin ( target, start [ , end ] )

チュートリアル

このメソッドの使い方は、Array.prototype.copyWithin()の説明をご参考下さい。同じ仕組みです。

デモ

TypedArray.prototype.copyWithin()のデモです。

<!-- このコードは編集できます。 -->

<!DOCTYPE html>
<html>
<head>
	<style>
body {
	white-space: pre-wrap ;
}
	</style>
</head>
<body>
<script>
/** try it! **/
var typedArray = new Uint8Array( [ 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08 ] ) ;
var a = typedArray.copyWithin( 0, 4, 8 ) ;
/** try it! **/

var results = { a:a, } ;

for( var name in results ) {
	console.log( name, results[name] ) ;
	document.body.appendChild( new Text( name + " = " + JSON.stringify( results[name] ) + "\n" ) ) ;
}
</script>
</body>
</html>

サポート状況

ChromeFirefoxSafariEdgeIEOperaiOS SafariAndroid
45+ 34+ 11.0+× 32+ 11.0+×
  • Twitterでシェア
  • Facebookでシェア
  • Google+でシェア
  • はてなブックマークでシェア
  • pocketに保存
  • LINEでシェア
更新履歴
2017年10月1日 (日)
コンテンツを公開しました。