yonkeltron.com

Temporary exile

Strings vs. Refernces: Optimizing Object-property Identifiers in JavaScript?

Am I crazy or is it inefficient to use strings as object-property identifiers for JavaScript objects?

panda = {"bamboo": 123,
              "tree": "Hello, there!",
              "curry": "Noo" + "dle"}

Since each of the object identifiers is an actual string and not a reference, I feel like it should be more memory-efficient to do it this way:

panda = {bamboo: 123,
              tree: "Hello, there!",
              curry: "Noo" + "dle"}

To me, the logic seems simple. Since strings take up more memory than references, it should be more efficient to use references in this case. Properties are still accessed the same way panda.bamboo should still yield 123 regardless of whether the object was defined with a string as an identifier or a references. Still, there are questions. When an object is defined using string identifiers, are they automagically converted to references on parse? What does this have to say about square-bracket accessor notation? For example, panda["curry"] is perfectly valid and should return "noodle" just as panda.curry would. The same process of string -> reference coercion would have to happen there, too, right? Does the behavior vary according to implementation? What’s the best thing to do?

Buy Discount online Cialis Buy Cialis new zealand Online Buy online ED pills UK. Viagra Buy Cialis 5mg online Buy Cialis United kingdom Buy 50 mg Viagra Buy Cialis without a prescription Cheap Levitra (vardenafil)