javascript - Broken object statement -
ok, might super dumb question doing review on objects in js , saw w3 schools example , tried doing own. didn't work, printed undefined. copied w3 schools right on , did work. changed names , didn't. asked 1 of coder friends , not figure out either. here's code i'm trying:
var car = {type:"fiat", model:"500", color:"white"}; var name = {first:"owen", last:"donnelly"};
when car.type prints fiat when type name.first says undefined.
"name" reserved keyword in javascript cannot use variable identifier. instead can use below:
var name = {first:"owen", last:"donnelly"};
Comments
Post a Comment