
JavaScript没有结构。
所以我可以在javascript中创建像struct abc这样的GLOBAL对象吗。
JavaScript是一种基于对象的动态语言,不使用C语言中的struct概念。
根据您的要求,您可以使用-
/* definition of an Object */
var xyz = function(age,name){
this.age = age;
this.name = name;
return this;
};
/* composition */
var abc = {
start:'',
end:'',
length:'',
xyz_pseudo_array: []
};
//push data inside the **xyz_pseudo_array** as and when needed, without having to worry about size-
abc.xyz_pseudo_array.push(new xyz(25,"Bill Gates"));