繁体   English   中英

如何使用格式说明符 output JavaScript 中的字符串或数字?

[英]How do I output a string or number in JavaScript using format specifier?

var b=4; //variable
document.write("The value  of b is %d", b);

在 Java 中,它将是:

int b;`
System.out.printf("the value of b is %d", b);

尝试这样做:

let b = 4;

let valueString = `The value of B is: ${b}`

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM