Safe string concatenation
来源:互联网 发布:淘宝直播刷人软件下载 编辑:程序博客网 时间:2024/05/22 13:13
Suppose you have a couple of variables with unknown types and you want to concatenate them. To be sure that the arithmetical operation would not be applied during the concatenation:
var one = 1;var two = 2;var three = '3';var result = ''.concat(one, two, three); //"123"
This way of concatenation does exactly what you expect. On the contrary, concatenation with pluses might lead to unexpected results:
var one = 1;var two = 2;var three = '3';var result = one + two + three; //"33" instead of "123"
Speaking about performance, in comparison with join type of concatenation, the speed of the concat type is pretty much the same.
You can read more about concat method on MDN page.
from:github/loverajoel
0 0
- Safe string concatenation
- String Concatenation
- String concatenation
- Avoiding String Concatenation
- string concatenation demo
- The Smallest String Concatenation
- Safe string in window
- the evil cmake -- string concatenation
- Efficient String Concatenation in Python
- C. The Smallest String Concatenation
- The Smallest String Concatenation CodeForces
- The Smallest String Concatenation CodeForces
- [Python] example-seven-string concatenation
- codeforces_632C.The Smallest String Concatenation(string)
- C#疑惑篇-literal string concatenation
- codeforces--623C The Smallest String Concatenation
- Codeforces 632C - The Smallest String Concatenation
- CodeForces-632C-The Smallest String Concatenation
- 前端性能优化
- myEclipse安装svn插件
- svn 合并的问题
- android webview无法加载网址
- 【bzoj2820】YY的GCD 莫比乌斯反演
- Safe string concatenation
- Android实现一键复制粘贴,兼容低版本系统(api 11以下)
- Win10 Ubuntu14.04 双系统 开机提示 error:no such partition grub rescue
- html5缓存(二)localStorage
- shiro安全框架
- switch语句能否作用在byte上,能否作用在long上,能否作用在String上?
- android相关下载
- java中for方法执行的正确顺序
- 复习iOS沙盒目录结构解析