String append: Difference between revisions

Content added Content deleted
Line 181: Line 181:
{{works with|Rhino}}
{{works with|Rhino}}
{{works with|SpiderMonkey}}
{{works with|SpiderMonkey}}
<lang JavaScript>var s = "Hello";
<lang JavaScript>var s1 = "Hello";
s += ", World!";
s1 += ", World!";
print(s);</lang>
print(s1);

var s2 = "Goodbye";
// concat() returns the strings together, but doesn't edit existing string
// concat can also have multiple parameters
print(s2.concat(", World!"));</lang>
{{out}}
{{out}}
<pre>
<pre>
"Hello, World!"
"Hello, World!"
"Goodbye, World!"
</pre>
</pre>