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

Popular posts from this blog

ios - Memory not freeing up after popping viewcontroller using ARC -

Django REST Framework perform_create: You cannot call `.save()` after accessing `serializer.data` -

Why does Go error when trying to marshal this JSON? -