Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #30277

Re: duplicator an array

Path csiph.com!news.mixmin.net!weretis.net!feeder1.news.weretis.net!news.solani.org!.POSTED!not-for-mail
From "Christoph M. Becker" <cmbecker69@arcor.de>
Newsgroups comp.lang.javascript
Subject Re: duplicator an array
Date Thu, 14 Apr 2016 19:41:55 +0200
Organization solani.org
Lines 26
Message-ID <neokoi$6k3$1@solani.org> (permalink)
References <ea578169-9d58-4249-91b4-e0cbad5a6fd8@googlegroups.com> <nen4e4$ggn$1@dont-email.me>
Mime-Version 1.0
Content-Type text/plain; charset=utf-8
Content-Transfer-Encoding 7bit
X-Trace solani.org 1460655698 6787 eJwNxcEBgDAIA8CVSIHgOlDJ/iPofS6d4K1gMlKpM7QJ4/V6uDXe7gVbvFoQmG5d5dFfWu8HFgIRow== (14 Apr 2016 17:41:38 GMT)
X-Complaints-To abuse@news.solani.org
NNTP-Posting-Date Thu, 14 Apr 2016 17:41:38 +0000 (UTC)
User-Agent Mozilla/5.0 (Windows NT 10.0; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.7.2
X-User-ID eJwFwYEBwCAIA7CXZlsqnuMY/H/CkqCXa8thxcTMqtMuN4wkpRefKTDnU/tidzLOhZVR+fwRiBBT
In-Reply-To <nen4e4$ggn$1@dont-email.me>
Cancel-Lock sha1:u5Z5YRn0Ze3Rd3YPT/LIKh5IuM0=
X-NNTP-Posting-Host eJwFwYEBwCAIA7CXdINWzinM/n/CknyxMQwkIp0eV6EJOygAY2rt0rT1CMzrdb5ORtTV4Q8v6xGx
Xref csiph.com comp.lang.javascript:30277

Show key headers only | View raw


On 14.04.2016 at 06:00, Aleksandro wrote:

> On 13/04/16 22:27, JRough wrote:
>
>> Okay, supposing the above works then I thought I would make an anonymous function in the duplicator method.  This would make it work the way the problem was first outlined above.  The only problem is how do I capture the value of the two arrays?
>>
>>
>> I guess you would do something like Array.prototype.duplicator = (function (){
>>     return  this.concat(arr.slice(0));
>> })()
> 
> Try:
> 
> Array.prototype.duplicate = function ()
> {
> 	this.push.apply(this, this.slice(0))
> }


The usual caveats wrt. augmenting built-in objects apply, though, see
e.g.
<http://peter.michaux.ca/articles/javascript-the-good-parts-built-in-object-augmentation-and-namespacing>.

-- 
Christoph M. Becker

Back to comp.lang.javascript | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

duplicator an array JRough <janis.rough@gmail.com> - 2016-04-13 18:27 -0700
  Re: duplicator an array Aleksandro <aleksandro@gmx.com> - 2016-04-14 01:00 -0300
    Re: duplicator an array JRough <janis.rough@gmail.com> - 2016-04-14 09:53 -0700
    Re: duplicator an array "Christoph M. Becker" <cmbecker69@arcor.de> - 2016-04-14 19:41 +0200
      Re: duplicator an array Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2016-04-14 22:09 +0200
        Re: duplicator an array Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2016-04-14 22:23 +0200
    Re: duplicator an array Stefan Weiss <krewecherl@gmail.com> - 2016-04-16 14:27 +0200
      Re: duplicator an array Joao Rodrigues <jr@none.com> - 2016-04-16 12:01 -0300
        Re: duplicator an array Joao Rodrigues <jr@none.com> - 2016-04-16 13:43 -0300
      Re: duplicator an array Aleksandro <aleksandro@gmx.com> - 2016-04-16 14:13 -0300
  Re: duplicator an array bharat.bandgar009@gmail.com - 2017-05-03 01:33 -0700

csiph-web