🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: adobe.scripting.indesign
Article #1872

Re: pls explain abt prototype

#1872
From: Simon_Paterson
Date: Wed, 21 Jan 2009 04:11
16 lines
1185 bytes
I use prototyping a lot for standard Javascript classes like Array. The function is then available to any Array that you create. For example:

      Array.prototype.contains = function (a)
      {
        for (var r = 0; r < this.length; r++)
          {
            if (this[r] == a) { return true; }
          }
        return false;
      }





You can then just use 'myArray.contains(myValue)' to find if the value is in the Array. If you were doing this with a function, you would need to send both the Array and the value to the function, so it's a little less elegant.
Technical Details
Message-ID: <59b78cbc.4@webcrossing.la2eafNXanI>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news.glorb.com!newshub.sdsu.edu!webcrossing
References: <59b78cbc.-1@webcrossing.la2eafNXanI>

Show Full Headers
Complete Article Headers
X-Google-Thread: f939a,ba3fc2ccca9a708d
X-Google-Attributes: gidf939a,domainid0,public,usenet
X-Google-Language: ENGLISH,ASCII-7-bit
From: Simon_Paterson@adobeforums.com
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news.glorb.com!newshub.sdsu.edu!webcrossing
Newsgroups: adobe.scripting.indesign
Subject: Re: pls explain abt prototype
Message-ID: <59b78cbc.4@webcrossing.la2eafNXanI>
Date: Tue, 20 Jan 2009 20:11:17 -0800
References: <59b78cbc.-1@webcrossing.la2eafNXanI>
Lines: 16
MIME-Version: 1.0
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit