Recently I am learning to make javascript class, I saw other people make class like this
var item = {
'a':{'b':1000,'c':2000,'d':3000} , //how to make a variable become an array?
myfunction : function(){
console.log(item.a.b); //and output item.a[1]?
}
};
item.myfunction();
But is it possible to make variable a an array? and output a variable item.a[1] like that?I tried
var a=new Array('1000','2000','3000')
but error, I need a correct syntax.
But that’s not a class, and there is no “variable a”.