Results 1 to 2 of 2

Thread: String statement equivelant

  1. #1
    Join Date
    Jul 2006
    Location
    Graham, NC
    Posts
    37
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default String statement equivelant

    Hi all. Just starting to delve into JavaScript and was wondering if there is any kind of String statement built in. Something like String("J",10), which would result in a string of 10 Js.

    Thanks in advance for any aid you all can provide.

  2. #2
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    No. You can write one:
    Code:
    String.prototype.dup = function(len) {
      var ret;
      for(var i = 0; i < len; ++i)
        ret += this;
      return ret;
    };
    ... then "J".dup(10);
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •