-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[js] 第51天 字符串相连有哪些方式?哪种最好?为什么? #200
Labels
js
JavaScript
Comments
Array.prototype.join
`${}`
+=
= '' + '' |
|
最好应该是 模板字符串`` |
var a = "aaaa"
var b = "bbbbb"
// 方法一: “+”
var c = a + b
console.log("c:", c)
// 方法二: “join("")”
var d = []
d.push(a,b)
console.log("d:", d.join(""))
// 方法三:模版字符串 `${}`
var e = `${a}${b}`
console.log("e:", e) |
|
const a = 'aaaaa';
const b = 'bbbbb';
- a + b
- `${a}${b}`
- a.concat(b)
- 循环遍历组装 |
应该是模板字符串 ${ a } 然后 字符串 '+' |
运算符+,模板字符串,concat |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
第51天 字符串相连有哪些方式?哪种最好?为什么?
The text was updated successfully, but these errors were encountered: