Hi I have a variable containing two arrays :
var x={ arr1:[] , arr2:[]};
I want to push new element to arr1, I try this but the word "push" does not appear as an option:
(x.arr1).push("hi");
and
x.arr1.push("hi");
EDIT
I'm really sorry , that thing above actually works , I thought it is the same as if the variable x was global var defined in another js file,I am new to JS .
So now let me explain more , x is a global variable defined in client.js file and there I set it with some properties, now I want to add more properties to it but from another js file called : server.js ,so I add these arrays to it as I mentioned above and when trying to push elements then it does not automatically completes the word "push".
client.js:
var gl={id: '123' ,
myfunc: function(){console.log("client func");}
};
server.js:
gl.arr1=[];
gl.arr1.push("hi"); //this does not work,it is like gl forgot about arr1
Sorry again..
{arr1: Array(2), arr2: Array(0)} arr1 : (2) ["hi", "hi"] arr2 : []What do you mean by "doesn't appear as an option"? Object introspection only goes so far.