Article View: pl.comp.lang.javascript
Article #51428Re: newbie: Array.prototype.inArray
From: NotBear
Date: Wed, 25 Jun 2014 15:03
Date: Wed, 25 Jun 2014 15:03
15 lines
1517 bytes
1517 bytes
W dniu 2014-06-25 16:20, jivanmukta@poczta.onet.pl pisze:
> Ale nie rozumiem właściwie dlaczego nie mogę dodać metody inArray do Array bezpośrednio. Przecież Array to obiekt.
Owszem, Array to obiekt, ale tylko dlatego, ze w JS niemal wszystko jest
obiektem :-). Array to konstruktor tablic. typeof Array zwraca 'function'.
Mozesz bezposrednio przypisac metode do konkretnej instancji tablicy, np:
var myArray = [];
myArray.inArray = function() {/*whatever*/}
Przypisanie do prototypu za to spowoduje, ze metoda bedzie dostepna we
wszystkich obiektach danego typu.
--
NotBear
Technical Details
Message-ID:
<loeobr$iul$1@node2.news.atman.pl>Path:
mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!agh.edu.pl!news.agh.edu.pl!newsfeed2.atman.pl!newsfeed.atman.pl!.POSTED!not-for-mailReferences:
<5f63dd2b-f8bc-4b93-9757-3b1eb2eea1c0@googlegroups.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!agh.edu.pl!news.agh.edu.pl!newsfeed2.atman.pl!newsfeed.atman.pl!.POSTED!not-for-mail From: NotBear <paulcom.HATESPAM@interia.pl> Newsgroups: pl.comp.lang.javascript Subject: Re: newbie: Array.prototype.inArray Date: Wed, 25 Jun 2014 17:03:20 +0200 Organization: ATMAN - ATM S.A. Lines: 18 Message-ID: <loeobr$iul$1@node2.news.atman.pl> References: <5f63dd2b-f8bc-4b93-9757-3b1eb2eea1c0@googlegroups.com> NNTP-Posting-Host: 217.17.39.162 Mime-Version: 1.0 X-Trace: node2.news.atman.pl 1403708603 19413 217.17.39.162 (25 Jun 2014 15:03:23 GMT) X-Complaints-To: usenet@atman.pl NNTP-Posting-Date: Wed, 25 Jun 2014 15:03:23 +0000 (UTC) User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.6.0 In-Reply-To: <5f63dd2b-f8bc-4b93-9757-3b1eb2eea1c0@googlegroups.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit