当前位置:网站首页>Join method in JS
Join method in JS
2022-07-26 21:59:00 【The life of elephants and ants】
js Medium join Method
join Method is used to put all elements in an array into a string .
The elements are separated by the specified separator .
vernacular :join Method can use different delimiters to construct this string .join Method value accepts a parameter , That is, the string used as the separator , Then return the string of all array items .
var arr = ["red","yellow","blue"];
var array = [];

Let's call join Method
1、
array = arr.join(undefined);
console.log(array);
The output is : red,yellow,blue.
because join Method parameters are not passed or passed undefined It will be separated by commas by default .
2、
array = arr.join("|");
console.log(array);
The output is : red|yellow|blue.
join Parameter is used "|" To separate
3、
array = arr.join(" | ");
console.log(array);
The output is : red | yellow | blue.
join Parameters use " | " To separate , String is separated by whatever it is .
4、
console.log(Array.isArray(array));
console.log(typeof array);
The output is :false String
If you use join To separate arrays , This variable will become a string type , Even if it was an array before, it will become a string type .
5、
console.log(array.join(" | "));
Error in output result : array.join is not a function
because array Now it has become a string , and join Only arrays can be called , So wrong reporting !
边栏推荐
- Oppo self-developed large-scale knowledge map and its application in digital intelligence engineering
- Go----Go语言中的变量使用方法
- Logical vulnerability - arbitrary account registration
- 45. Instance segmented labelme dataset to coco dataset and coco dataset to labelme dataset
- Samsung releases 108million pixel image sensor isocell bright HMX, and Xiaomi will launch
- JDBC总结
- 我的sql没问题为什么还是这么慢|MySQL加锁规则
- JDBC operation and entry case of MySQL
- 五、小程序报错:message:Error: 系统错误,错误码:80058,desc of scope.userLocation is empty
- 商汤科技发布人脸识别一体机SensePass Pro
猜你喜欢

1 - "pytorch deep learning practice" - linear model

FreeRTOS personal notes - Software Timer
![[mysql]substr usage - query the value of specific digits of a field in the table](/img/d5/68658ff15f204dc97abfe7c9e6b354.png)
[mysql]substr usage - query the value of specific digits of a field in the table

2022年简历石沉大海,别投了,软件测试岗位饱和了....

Alkbh1

新来个技术总监要我做一个 IP 属地功能~

cmake编译obs-studio-27.2.0

深入源码剖析String类为什么不可变?(还不明白就来打我)

Pytorch--Visdom使用

Pytoch uses RNN model to build person name classifier
随机推荐
Six instructions of Memcache based caching mechanism
Talk about TCP time_ WAIT
Can I view the history in the "stealth" mode of the secure browser?
吃透负载均衡
Circular progress bar animation based on cashapelayer and Bezier curve
Leetcode exercise - Sword finger offer II 005. maximum product of word length
Just one dependency to give swagger a new skin, which is simple and cool
基于CAShapeLayer和贝塞尔曲线的圆形进度条动画
6、 Wechat applet release process
Search Yiwu shopping (PAI Li Tao) API by image
Ren Zhengfei talked about the suppression of the United States again: to live is to win, and to defeat the United States
25 cool interactive charts, one entry plotly
Finding a new direction for the development of digital retail is the key to ensure that digital retail can enter a new stage of development
Also on Data Governance
技术分享 | 服务端接口自动化测试, Requests 库的这些功能你了解吗?
It is said that Samsung obtained EUV photoresist from Belgium
Flag decodes token, mounts token, decorator, and seven cattle cloud upload
商汤科技发布人脸识别一体机SensePass Pro
伟创力回应“扣押华为物料”事件:深感遗憾,期待继续合作!
会用redis吗?那还不快来了解下redis protocol