这个 达雷。toString() 是JavaScript中的一个内置函数,用于将tyepdArray的内容转换为字符串。
null
语法:
typedarray.toString()
参数: 此函数不接受任何参数。
返回值: 它返回一个表示typedArray元素的字符串。
<script> // Constructing a new typedArray Uint8Array() object const A = new Uint8Array([5, 10, 15, 20, 25, 30, 35]); // Converting the elements of typedArray // object into string const B = A.toString(); // Printing converted string document.write(B); </script> |
输出:
5,10,15,20,25,30,35
代码#2:
<script> // Constructing a new typedArray Uint8Array() object const A = new Uint8Array([ "gfg" , "CSE" , "GeeksForGeeks" ]); // Converting the elements of typedArray // object into string const B = A.toString(); // Printing converted string document.write(B); </script> |
输出:
0,0,0
这里的输出是零,因为typedArray的内容应该是数字而不是字符串。
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END