Javascript Object Question 4

Introduction

What is the output of the following code?

// "{}" same as "new Object()"
// Recommended way
// Faster & easier to write
var person = {/*from   w w  w .  j  a  va  2s  . co m*/
    fname: "CSS", 
    lname: "HTML", 
    address: {
        street: "1000 Main St.", 
        apt: "10A"
    }
};

console.log("fname: " + person.fname);
console.log("lname: " + person.lname);

console.log("street: " + person.address.street);
console.log("street: " + person["address"]["street"]);
console.log("street: " + person["address"].street);
console.log("street: " + person.address["street"]);

console.log(person);


fname: CSS
lname: HTML
fname: CSS
lname: HTML
street: 1000 Main St.
street: 1000 Main St.
street: 1000 Main St.
street: 1000 Main St.



PreviousNext

Related