Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to inspect an object's property if the property name is an empty string?

Javascript objects' properties can be named with the empty string, for example:

foo = { 
    "" : "bar"
}

Dot notation does not seem to be able to call this property. Console output:

foo.
>> "missing name after . operator"

How would you call the "" property?

like image 901
Choylton B. Higginbottom Avatar asked Jun 01 '15 20:06

Choylton B. Higginbottom


1 Answers

Use an empty string as a key with the bracket syntax:

foo[""]
like image 146
Nicholas Thomson Avatar answered Sep 30 '22 19:09

Nicholas Thomson