首页 > Web开发 > 详细

JS 字符串拼接

时间:2017-04-09 12:41:57      阅读:133      评论:0      收藏:0      [点我收藏+]

语法如下:

str.concat(string2[, string3, ..., stringN])


示例:

var hello = ‘Hello, ‘;
console.log(hello.concat(‘Kevin‘, ‘ have a nice day.‘));
/* Hello, Kevin have a nice day. */

var greetList = [‘Hello‘, ‘ ‘, ‘Venkat‘, ‘!‘];
"".concat(...greetList); // "Hello Venkat!"

"".concat({}); // [object Object]
"".concat([]); /// ""
"".concat(null); // "null"
"".concat(true); // "true"
"".concat(4, 5); // "45"
"".concat({}); // [object Object]

 

JS 字符串拼接

原文:http://www.cnblogs.com/spring87/p/6684157.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!