Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

178
Views
Deleting a non-string in js object

Let's say I have the following object:

const a = {a: 1, 0: 2};
delete a.a; // this works
delete a.0; // this errors (I suppose expecting a['0'] and not a[0])

Does the method deletion form of obj.key only allow deletion of a string key? And if it's a non-string type, is the only way of doing deletion via the key lookup method of obj[key] ?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

According to MDN:

In the object.property syntax, the property must be a valid JavaScript identifier.

... where ...

... identifiers are case-sensitive and can contain Unicode letters, $, _, and digits (0-9), but may not start with a digit.

So, answering your question, property with name 0 can be only accessed with key notation.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!