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


Groups > it.comp.lang.javascript > #7986

Re: Approfondire Javascript

From g4b0 <gabriele.brosulo@gmail.com>
Newsgroups it.comp.lang.javascript
Subject Re: Approfondire Javascript
Date 2016-01-25 15:00 +0100
Organization Aioe.org NNTP Server
Message-ID <n859q5$l9l$1@gioia.aioe.org> (permalink)
References (1 earlier) <2016011514270221669@mynewsgate.net> <56991466.7030502@gmail.com> <2016011516424221669@mynewsgate.net> <56A0F909.8060508@gmail.com> <7fd10a00-f714-4637-9333-3f75b62bae92@googlegroups.com>

Show all headers | View raw


On 21/01/2016 21:18, 4ndre4 wrote:
> Il metodo migliore per costruire oggetti e` usare il constructor/prototype pattern:
> 
> function Dog(name, breed) {
>     this.name = name;
>     this.breed = breed;
> }
> 
> Dog.prototype.bark = function() {
>     alert(this.name + ': arf! arf!');
> };
> 
> Dog.prototype.howl = function() {
>     alert(this.name + ': ouuuuuuu!')
> }
> 
> var dog1 = new Dog('Fido', 'German Shepherd');
> var dog2 = new Dog('Pluto', 'Bloodhound');
> 
> dog1.bark();
> dog2.howl();

Avevo letto da qualche parte che dal punto di vista delle performance
passare attraverso il prototype è meno performante che dichiarare i
metodi direttamente, ma forse era un articolo datato...

Però firefox che nella console mi segnala questo warning:

mutating the [[Prototype]] of an object will cause your code to run very
slowly; instead create the object with the correct initial [[Prototype]]
value using Object.create

In realtà non indica il codice a cui si riferisce, per cui forse sono io
che faccio confusione. Oppure no?

-- 
g4b0, linux user n. 369000
http://brosulo.net

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


Thread

Approfondire Javascript g4b0 <gabriele.brosulo@gmail.com> - 2016-01-15 14:10 +0100
  Re: Approfondire Javascript "ciccio" <21669invalid@mynewsgate.net> - 2016-01-15 14:27 +0000
    Re: Approfondire Javascript "ciccio" <21669invalid@mynewsgate.net> - 2016-01-15 14:29 +0000
    Re: Approfondire Javascript g4b0 <gabriele.brosulo@gmail.com> - 2016-01-15 16:46 +0100
      Re: Approfondire Javascript "ciccio" <21669invalid@mynewsgate.net> - 2016-01-15 16:42 +0000
        Re: Approfondire Javascript g4b0 <gabriele.brosulo@gmail.com> - 2016-01-15 17:57 +0100
        Re: Approfondire Javascript g4b0 <gabriele.brosulo@gmail.com> - 2016-01-21 16:28 +0100
          Re: Approfondire Javascript 4ndre4 <a.laforgia@gmail.com> - 2016-01-21 12:18 -0800
            Re: Approfondire Javascript g4b0 <gabriele.brosulo@gmail.com> - 2016-01-25 13:54 +0100
              Re: Approfondire Javascript 4ndre4 <a.laforgia@gmail.com> - 2016-01-25 06:52 -0800
                Re: Approfondire Javascript 4ndre4 <4ndre4@4ndre4.com.invalid> - 2016-01-25 18:40 +0000
            Re: Approfondire Javascript g4b0 <gabriele.brosulo@gmail.com> - 2016-01-25 15:00 +0100
  Re: Approfondire Javascript Andrea Scartabelli <nome.cognome@dallepartidibigg.com> - 2016-01-15 20:31 +0100
    Re: Approfondire Javascript oss <oss@mailnesia.com> - 2016-01-18 14:56 +0100
      Re: Approfondire Javascript Andrea Scartabelli <nome.cognome@dallepartidibigg.com> - 2016-01-18 20:18 +0100
        Re: Approfondire Javascript oss <oss@mailnesia.com> - 2016-01-18 20:53 +0100
  Re: Approfondire Javascript 4ndre4 <a.laforgia@gmail.com> - 2016-01-15 11:39 -0800
  Re: Approfondire Javascript Alessandro Pellizzari <shuriken@amiran.it> - 2016-01-15 20:11 +0000
    Re: Approfondire Javascript 4ndre4 <a.laforgia@gmail.com> - 2016-01-16 10:24 -0800
      Re: Approfondire Javascript Alessandro Pellizzari <shuriken@amiran.it> - 2016-01-16 21:07 +0000
        Re: Approfondire Javascript "ciccio" <21669invalid@mynewsgate.net> - 2016-01-17 11:44 +0000
          Re: Approfondire Javascript Alex <tommaso5ita@yahoo.it> - 2016-01-17 20:14 +0100
  Re: Approfondire Javascript g4b0 <gabriele.brosulo@gmail.com> - 2016-01-19 14:29 +0100
    Re: Approfondire Javascript g4b0 <gabriele.brosulo@gmail.com> - 2016-01-21 15:03 +0100
      Re: Approfondire Javascript 4ndre4 <a.laforgia@gmail.com> - 2016-01-21 08:54 -0800

csiph-web