Den söndag 22 maj 2016 kl. 08:42:41 UTC+2 skrev jonas.t...@gmail.com:
> Den söndag 22 maj 2016 kl. 01:41:58 UTC+2 skrev Aleksandro:
> > On 21/05/16 13:41, jonas.thornvall@gmail.com wrote:
> > > I have an object storing integers, many formulas may of course generate the same integer. And for some expressions for example on form a*x^j i would like to store each occurence. Now all my numbers are printed out in a square grid.
> > >
> > > Right now the storing structure look like this and i set fontcolor and rectangle color as i print out the grid.
> > >
> > > However i would like to store multiple func and rcolors within same object?
> > > Thus make func and rcolor the multidimensional part of the array.
> > >
> > > I am totally clueless for how both initiate and update such an object in javascript. I have managed to do it for numbers but i never initiated the object it was somehow forked in as i updated the object. And i really did not understand how it really worked. So if someone could show me howto make this array of integers to holld multiple functions and rectangles for each arr[i] it would be great.
> > >
> > > function arraysize()
> > > {
> > >
> > > for ( i = - scope; i <= scope; i ++ )
> > > {
> > > arr[i] =
> > > {
> > > count : i,
> > > func : '',
> > > fcolor : 'black',
> > > rheight : 100,
> > > rwidth : 100,
> > > rcolor : 'white',
> > > prime : true,
> > > formula : 0,
> > > sigma : 0,
> > > }
> > > }
> > > }
> > >
> >
> > Sorry but I am drunk lol I wall think for an ann-er in the morning lololol
>
> Lets hope you sobered up...
> var x = new Array(10);
> for (var i = 0; i < 10; i++) {
> x[i] = new Array(20);
> }
> x[5][12] = 3.0;
>
> How does this relate to my example array above?
> I do not know how many occurences there will be, and it is only the func and rcolor property of the object that will be multidimensional.
>
> for ( i = - scope; i <= scope; i ++ )
> {
>
> arr[i] =
> {
> count : i,
> func : '',
> fcolor : 'black',
> rheight : 100,
> rwidth : 100,
> rcolor : 'white',
> prime : true,
> formula : 0,
> sigma : 0,
> }
> arr[i] = new Array(20);//??????????
> }
> }
If i let out 20 above, arr[i] = new Array(); will the subarray dynamically assign memory as i pass new properties?
So to update the object i use arr[x][y].func="mystring" or arr[x][y].rcolor="green".
Is there space allocated for the rest of the attributes/properties of the object?
Does the object creation and the update seem right?