How to concatenate two numbers in javascript?

后端 未结 16 2399
傲寒
傲寒 2020-12-13 16:33

I\'d like for something like 5 + 6 to return \"56\" instead of 11.

16条回答
  •  感情败类
    2020-12-13 17:12

    Use "" + 5 + 6 to force it to strings. This works with numerical variables too:

    var a = 5;
    var b = 6;
    console.log("" + a + b);

提交回复
热议问题