我想输出:
[2, [23]]
但是,当我运行时:
console.log([2,[23]]);
我得到:
(2) [1, Array(1)]
我尝试使用 toString()
方法,但我得到的是 '2,23'
。
最佳答案
您无法获得完全相同的表示(尤其是因为它因环境而异),但 JSON.stringify
将接近:
var s = JSON.stringify([2,[23]]); // s gets "[2,[23]]"
document.body.appendChild(
document.createTextNode(s)
);
关于javascript - 如何打印控制台登录变量?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49455382/