What does var = {} mean?

Discussion in 'JavaScript' started by knapsack3, Sep 28, 2007.

  1. #1
    Hi,

    I have a statement like
    var a = {};

    Does that mean a is an object or an array?

    Also, later in the code I have something like
    a.name = "temp";
    a.age = 25;
    etc.,

    Now, how do I access a's variables dynamically? i.e a method like

    getDetails(fieldname){
    return ( a.eval(fieldname));
    }
    But eval() throws an error in IE.
    Any suggestions please.
    thanks.
     
    knapsack3, Sep 28, 2007 IP
  2. Grue

    Grue Peon

    Messages:
    6
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Yes, var a{}; is an object, you're declaring it using Object Literal notation.
    Check the wikipedia page for Object_literal.

    You seem to have answered your other question in a followup post.
     
    Grue, Sep 28, 2007 IP