开发者

PHP's Dot Equals `.=` operator in Javascript?

开发者 https://www.devze.com 2022-12-15 01:20 出处:网络
How can you use PHP\'s Dot Equals .= operator in开发者_运维知识库 Javascript?What you are mentioning is a contatenation equals operator which sets the value of the left hand operand to a string contai

How can you use PHP's Dot Equals .= operator in开发者_运维知识库 Javascript?


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";


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 += ',';


use += eg:

a = 'Hello'
a += 'World'


 var a = "";
 a += "fff";
0

精彩评论

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