1

Is there any caveat/problem in creating/accessing JS object keys (properties) using long text strings?

Example:

let obj={}
let key1="long time ago\nthere was a long text string\nto be used to index object's properties\n";
let value1=[7,13,10];
obj[key1] = value1;

PS: By long, I mean 300~1000 characters text string, that contain newlines.

My aim is to create a cache object, with input (object property) being the raw text and the output (stored as value) being some computations with this text. This could be better than hashing the string before using it as an object property?

Berk7871
  • 187
  • 1
  • 2
  • 14
  • Do you ever plan on attempting to reference the key with dot notation? Have you considered using Symbols? – chazsolo Jul 11 '19 at 18:30

0 Answers0