+=
运算符来concatenate(拼接)字符串到现有字符串的结尾。对于那些被分割成几段的长的字符串来说,这一操作是非常有用的。
提示+=
操作符来连接这两个字符串:"This is the first sentence. "
和"This is the second sentence."
并赋给变量myStr
。
myStr
的值应该是This is the first sentence. This is the second sentence.
。
testString: assert(myStr === "This is the first sentence. This is the second sentence.");
- text: 使用+=
操作符创建myStr
变量。
testString: assert(code.match(/\w\s*\+=\s*["']/g).length > 1 && code.match(/\w\s*\=\s*["']/g).length > 1);
```