且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在javascript中连接两个数字?

更新时间:2023-02-10 09:50:50

使用+ 5 + 6 强制它为字符串。这也适用于数值变量:

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

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