当前位置:网站首页>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 !
边栏推荐
- [mysql]substr usage - query the value of specific digits of a field in the table
- 寻找数字零售的发展新方向,才是保证数字零售可以进入到全新发展阶段的关键
- 伟创力回应“扣押华为物料”事件:深感遗憾,期待继续合作!
- July training (the 26th day) - and check the collection
- 虾皮shopee根据ID取商品详情 API
- LDAP——实现用户统一登录管理
- A new technical director asked me to do an IP territorial function~
- Flink's real-time data analysis practice in iFLYTEK AI marketing business
- Flextronics responded to the "seizure of Huawei materials" incident: deeply regretted, looking forward to continuing cooperation!
- Happens-Before原则深入解读
猜你喜欢

Logical vulnerability - arbitrary account registration

七、微信小程序运行报错:Error: AppID 不合法,invalid appid

也谈数据治理

Summer vacation daily question week 7:7.18 - 7.24

OPPO 自研大规模知识图谱及其在数智工程中的应用

imshow()函数后面如果不加waitKey()函数就不显示

现货黄金操作指南与建议(上)

A new technical director asked me to do an IP territorial function~

6、 Wechat applet release process

带你搞懂MySQL隔离级别,两个事务同时操作同一行数据会怎样?
随机推荐
梦里的一碗面
仅需一个依赖给Swagger换上新皮肤,既简单又炫酷
NPM, NPM Chinese documents, NPM learning and using
6、 Wechat applet release process
Pytorch torch.add() torch.add_() 用法
Isilon 的OneFs常见操作命令(一)
Technology sharing | do you know the functions of the server interface automated testing and requests library?
Summer vacation daily question week 7:7.18 - 7.24
OPPO 自研大规模知识图谱及其在数智工程中的应用
Go----Go 语言中的标识符和关键字
《暑假每日一题》Week 7:7.18 - 7.24
Dream weaving prompt dedecms error:tag disabled:php!
VI and VIM text editors
flask 源码启动阶段
Is it safe to open an account on flush? How to choose a securities firm for opening an account
Resume in 2022 is dead in the sea. Don't vote. Software testing positions are saturated
Thoroughly understand the principle and implementation of service discovery
浏览器主页被篡改怎么办,主页被篡改恢复方法
25 cool interactive charts, one entry plotly
Shangtang technology releases sensepass pro, an all-in-one face recognition machine