开发者

Simple question: How to do variable concatenation in JavaScript?

In php I can have something like this:

$animal = 'horse';

$animal += ', tig开发者_StackOverflow社区ers';

then the value of animals would be "horse, tigers". How do I do this type of variable concatenation in JavaScript?


Surprise:

'horse' + ', tigers'; // 'horse, tigers'

Now read a good tutorial before asking a thousand more questions:
https://developer.mozilla.org/en/JavaScript/Guide


var szTest = "";
szTest += "One";
szTest += ", Two";


In Javascript you can use the + to concatenate strings like so,

'horse' + ', tigers';

In PHP the string concatenation operator is .. So, your example should be:

$animal = 'horse';

$animal .= ', tigers';


var $animal = 'horse';

$animal += ', tigers';
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜