Write More Robust JavaScript: 7 Best Practices

Write code that’s less likely to break, hopefully

Jan 16 · 5 min read
Photo by Farzad Nazifi on Unsplash

Best Practices for More Robust JavaScript

1. Use factory functions

2. Add methods on the .prototype when writing constructors

3. Use the conventional .type property when differentiating

4. Use TypeScript

5. Write tests

6. Keep functions as simple as possible

7. Always consider using try/catch when using JSON.parse or JSON.stringify

SyntaxError: Unexpected token } in JSON at position 107


Better Programming

Advice for programmers.


Written by

Team Lead Front End Developer for TeleMedicine. Follow and Join Me on my Adventures. https://jsmanifest.com

Better Programming

Advice for programmers.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade