可能重複:
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