regular array vs object array. same prototypes? or features?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Samishii23
    New Member
    • Sep 2009
    • 246

    regular array vs object array. same prototypes? or features?

    I was wondering, since I'm about to embark on an heavy object array project. As I was studying arrays, I was wondering if Object arrays are treated the same?

    like:
    Code:
    var arr1 = [];
    arr1.push(1,2,3);
    // arr1 = [1,2,3];
    
    var obj1 = {};
    obj1.push(id:1);
    // obj1 = {id:1};
    This probably doesn't work does it?
    How do you go about adding on to existing objects, or is that a downside to using object arrays that its static and can't be updated, but completely redefined?

    And if so, how should I go about taking an existing object array, and new array elements to add to the old, and combine?
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    This probably doesn't work does it?
    of course. an Object is not an Array and .push() is an Array method.

    there is no such thing as an object array (in your meaning), it’s just a plain object. adding a new property to an object is simple: obj.newMember = value;

    Comment

    Working...