可能重复:
JavaScript equivalent to printf/string.format打印在javascript复杂的字符串,而不+符号
有没有像这样一个以上的C打印复杂的字符串在JavaScript中,最好是不需要大量的+
符号和伴随的""
?
我想这样:
console.log ("Name: %s Age: %s Sex %s Wieght %s Height %s", name, age, sex, weight, height);
取而代之的是:
console.log ("Name: " + name + " Age: " + age + " Sex: " + sex + " Weight: " + weight " Height: " + height);
http://stackoverflow.com/questions/610406/javascript-equivalent-to-printf-string-format – Lance 2012-07-18 21:15:39
@兰斯我的坏。我搜索了除“javascript ... printf”之外的所有内容。我会投票结束 – puk 2012-07-18 21:17:44