Talk:Core JavaScript 1.5 Guide:Operators:String Operators
From MDC
[edit] String repetition operator in Javascript
Javascript seems to be missing a String repetition operator like 'x' in Perl.
It's a pity because the Perl way
var message = "I am a fish " x 80;
is much more concise than the Javascript way:
function StringRepeat(s,count) { for (var r="",i=0; i<count; i++) {r+=s;} return r;}
var message = StringRepeat("I am a fish ",80);
Or am I missing something? --Hamstersoup 03:33, 3 March 2007 (PST)
- No, you're not missing anything. It's not there, for whatever reason. --Waldo 19:03, 3 March 2007 (PST)