javascript - How to create a random JS object? -
i know if there way of creating javascript object randomized. understand randomized such: resulting object has random set of properties, every of has random name. problem boils down two:
1) possible have object created @ runtime, without earlier specifying amount of properties?
2) possible randomize names of object's properties?
i'm looking explanation/solution, not no/yes answer.
a crude way it, can't think of use case it:
function randomobject(){ var ret = {}; var propertycount= math.random() * 10; (var x = 0; x < propertycount; x++ ){ ret[math.random()] = math.random(); } return ret; }
Comments
Post a Comment