- %s 字符类型(String)
- %d, %i 整型(Integer)
- %f 浮点类型(Floating)
- %O 对象类型(Object)
%? 可以在 console.log() 中控制插入的位置和数据类型
demo
console.log("1 %s 3", "+")
//1 + 3
console.log("1 %d 3", "+")
//1 NaN 3
console.log("1 %d 3", 2)
//1 2 3
可以使用多个 %?, 插入的值与顺序对应
demo
console.log("1 %s 3 = %d", "+", 4)
//1 + 3 = 4
参考资料:console.log()中的%d,%s等代表的输出类型
end