How to concatenate variables in javascript?

后端 未结 3 672
梦谈多话
梦谈多话 2021-01-29 15:41

I am trying to concatenate variables in inside a function and then return. In php we just put a period before the \"=\" but it is not working in javascript.

Can someone

3条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-29 16:26

    "+=" is the standard way to concatenate in javascript;

    var a = "yourname";
    var b = "yourlastname";
    var name = a + b;
    var complete_name = "my name is: ";
    complete_name += name;
    

    result : my name is: yourname yourlastname

提交回复
热议问题