Javascript教程
JavaScript基础
JavaScript Objects
JavaScript BOM
JavaScript DOM
JavaScript OOP
JavaScript Cookies
JavaScript事件
JavaScript异常
JavaScript常用

TypedArray join()

JavaScript TypedArray join()方法

JavaScript join()方法用于将Array的所有元素连接到字符串中。元素将由指定的分隔符分隔。默认的分隔符是逗号(,)。

语法:

Array.join(separator)

参数:

它是可选的,可以用作参数,也可以不将其默认值为(,)。

返回值:

它返回包含数组元素集合的String。

浏览器支持:

浏览器 版本
Chrome 1.0
Edge
Firefox 1.0
Opera

示例

JavaScript TypedArray join()方法
<script type="text/javascript">
// JavaScript to illustrate join() method
  // input array
var lidihuo = ['core java','C'];
//joins the elements of the array.
document.write("joins the elements of the array <br>");
document.write(lidihuo.join());
document.write("<br>");
//elements are seperated by dot (.).
document.write("elements are seperated by dot (.) <br>");
document.write(lidihuo.join('.'));
document.write("<br>");
//elements are seperated by hyphen (-).
document.write("elements are seperated by hyphen (-)<br>");
document.write(lidihuo.join('-'));
// expected output: arr[core javaC
//core java.C
//core java-C]
</script>
输出:
core Java,C
core java.C
core Java-C
昵称: 邮箱:
Copyright © 2022 立地货 All Rights Reserved.
备案号:京ICP备14037608号-4