且构网

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

如何将 2 个 javascript 变量组合成一个字符串

更新时间:2023-01-13 16:27:02

使用 连接运算符 +,以及数字类型会自动转换为字符串的事实:

Use the concatenation operator +, and the fact that numeric types will convert automatically into strings:

var a = 1;
var b = "bob";
var c = b + a;