var obj = {
'foo' : 'bar',
'something very, very, very, very long' : 'baz'
};
Any limits on how long that property name can be?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
From my briefest empirical studies, there is no limit enforced by javascript, at least not as implemented by Chrome. It is simply a question of how much memory your machine allows the script engine to consume before the application crashes.
During my tests, a managed to create an object containing a property with a 268 435 456 chars long name, but trying again at 536 870 912, my browser crashed.
I don’t believe it would be of any interest to find where my threshold is with any greater accuracy than that, since this should prove that any limits that are there, are entirely imposed by the capacity of the machine, rather than by specs.
Oh, and at 67 108 864 chars, I started noticing performance issues when assigning properties 🙂