Append to string variable [closed]

可紊 提交于 2019-12-17 05:46:29

问题


How can I append a word to an already populated string variable with spaces?


回答1:


Like this:

var str = 'blah blah blah';
str += ' blah';

str += ' ' + 'and some more blah';



回答2:


var str1 = 'abc';
var str2 = str1+' def'; // str2 is now 'abc def'



回答3:


var str1 = "add";
str1 = str1 + " ";

Hope that helps,

Dan




回答4:


Ronal, to answer your question in the comment in my answer above:

function wasClicked(str)
{
  return str+' def';
}


来源:https://stackoverflow.com/questions/1288095/append-to-string-variable

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!