views:

456

answers:

4

How can you use PHP's Dot Equals .= operator in Javascript?

A: 

I assume that the .= operator is used for string concatenation?

In Javascript the + operator is used for string concatenation, and the += operator for reassigning the string to the same variable. Example:

s += ',';
Guffa
A: 

use += eg:

a = 'Hello'
a += 'World'
z33m
+4  A: 

What you are mentioning is a contatenation equals operator which sets the value of the left hand operand to a string containing a concatenation of its value appended with the string in the right hand operand.

You can do the same operation in javascript using the += operator.

var str = "test";

str += " appended string";
rahul
A: 
 var a = "";
 a += "fff";
andres descalzo