Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #34635
| Newsgroups | comp.lang.javascript |
|---|---|
| Date | 2018-01-22 21:36 -0800 |
| References | (4 earlier) <kgl96dda6o6b8kn4j6ut7fj14i4ot7eklq@4ax.com> <f63278fa-0cd4-4681-96b9-455d520f4c6a@googlegroups.com> <86gb6ddabbi3aga2609e2need5absic73r@4ax.com> <380d7510-683d-420c-9564-095c04ebcce5@googlegroups.com> <kd4c6d5tpnnuotlbfei2ivckpo2v4oeio2@4ax.com> |
| Message-ID | <d37e2907-043f-4089-86e8-bf4e0e2c7338@googlegroups.com> (permalink) |
| Subject | Re: DATA Structure one last time |
| From | Jonas Thörnvall <jonas.thornvall@gmail.com> |
Den måndag 22 januari 2018 kl. 17:32:41 UTC+1 skrev John G Harris:
> On Mon, 22 Jan 2018 04:32:00 -0800 (PST), Jonas Thörnvall
> <jonas.thornvall@gmail.com> wrote:
>
> <snip>
> >The syntax "it is always the syntax"
> >
> >And honestly i can not see any reason why
> >
> >track[m].midiMess[n].time=whatever
> >
> >Would be equivalent to push "assign a value to object [n] because ones it created that is how you can assign it a new value.
>
> track[m].midiMess
> is an array object.
>
> track[m].midiMess[n]
> is an element of that array.
>
> IF you have put a message object into that element, by doing something
> like
> track[m].midiMess[n] = { /*a message object*/ };
> then
> track[m].midiMess[n].time
> is a property of that message object. You can read from and write to
> it.
>
> BUT if you have never put anything into that element then the element
> doesn't have properties (it's not an object; it's undefined).
>
>
> You don't have to use push. You could do it the old-fashioned way :
> var size = track[m].midiMess.length;
> track[m].midiMess[size+1] = { /*Object you want to add*/ };
> That's all that push does.
So track[m].midiMess[n] would have worked afterall, fuck now i get even more tired.
So it was just the curly paragraphs missing, fuck you people really evil LoL
No i mean it you are evil, anal anal retentive.
>
> >I probably should do it in a more object oriented way set all the properties at once and not one at a time, but yet again i do not know the syntax.
>
> "all the properties at once"! There's thousands of them, you said.
>
> >I could guess
> >track[m].midiMess[n]={time=clock,data0=mess0,data1=mess1,data2=mess2};
> >Is that correct or I should probably use colons?
> >But again it is not easy to guess the syntax to assign a subarray values, because that is what one do when one can not find appropriate examples.
>
> track[m].midiMess[n]
> = {time:clock, data0:mess0, data1:mess1, data2:mess2};
>
> An appropriate example :
>
> var arr = []; // An empty array
> // ...
> arr[5] = {first:"alpha", second:"beta"};
> // Element 5 now holds an object
>
> John
Thank's John great Job!!! I think i save it until i forget the syntax next time.
There is teacher material in you, for sure!!!
Don't mind about my comments, they are more a sign of my shortcomings then yours.
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
DATA Structure one last time Jonas Thörnvall <jonas.thornvall@gmail.com> - 2018-01-21 01:50 -0800
Re: DATA Structure one last time Jonas Thörnvall <jonas.thornvall@gmail.com> - 2018-01-21 02:09 -0800
Re: DATA Structure one last time Jonas Thörnvall <jonas.thornvall@gmail.com> - 2018-01-21 03:35 -0800
Re: DATA Structure one last time Jonas Thörnvall <jonas.thornvall@gmail.com> - 2018-01-21 04:10 -0800
Re: DATA Structure one last time John G Harris <niam@jghnorth.org.uk.invalid> - 2018-01-21 18:04 +0000
Re: DATA Structure one last time Jonas Thörnvall <jonas.thornvall@gmail.com> - 2018-01-21 20:03 -0800
Re: DATA Structure one last time Jonas Thörnvall <jonas.thornvall@gmail.com> - 2018-01-21 20:07 -0800
Re: DATA Structure one last time John G Harris <niam@jghnorth.org.uk.invalid> - 2018-01-22 10:47 +0000
Re: DATA Structure one last time Jonas Thörnvall <jonas.thornvall@gmail.com> - 2018-01-22 04:32 -0800
Re: DATA Structure one last time John G Harris <niam@jghnorth.org.uk.invalid> - 2018-01-22 16:32 +0000
Re: DATA Structure one last time Jonas Thörnvall <jonas.thornvall@gmail.com> - 2018-01-22 21:36 -0800
Re: DATA Structure one last time Jonas Thörnvall <jonas.thornvall@gmail.com> - 2018-01-23 01:22 -0800
Re: DATA Structure one last time Jonas Thörnvall <jonas.thornvall@gmail.com> - 2018-01-23 05:18 -0800
Re: DATA Structure one last time Jonas Thörnvall <jonas.thornvall@gmail.com> - 2018-01-23 05:38 -0800
Re: DATA Structure one last time Jonas Thörnvall <jonas.thornvall@gmail.com> - 2018-01-23 05:44 -0800
Re: DATA Structure one last time Jonas Thörnvall <jonas.thornvall@gmail.com> - 2018-01-23 06:07 -0800
csiph-web