+=
运算符将字符串连接到现有字符串变量的末尾。这对于在多行上打破长字符串非常有帮助。 注意 myStr
几行: "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.", "myStr
should have a value of 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, "Use the +=
operator to build myStr
");'
```