Since JavaScript is one of the most popular languages nowadays, there’s a lot of obsolete and wrong information about it on the web. This makes new developers propagate bad practices and bad code. This must stop. JS: The Right Way is an easy-to-read, quick reference for JS best practices, accepted coding standards, and links around the Web.
This is a work in progress. We are working with the community to create this guide. So if you want to help, feel free to contribute on GitHub.
It’s important to know that JavaScript has some bad parts, but also does have nice ones! And those nice parts make it worth. It’s a fun language to work with, and if you know how to use it in the “right way”, you can enjoy programming on it.
We also ensure that there’s no really “right way” to work with JavaScript. There’s many ways, and this makes each programmer and each language unique. Here we just introduce new JavaScript developers and also experienced ones to follow best practices and get references, such as follow the creators and big names of JavaScript community.
This is a living document and will continue to be updated with more helpful information and examples as they become available.
Help make this website the best resource for new JavaScript programmers! Contribute on GitHub
Send to your friends and put a link on your website. Help grow the best practices and good information about JavaScript!
JavaScript (sometimes shortened to JS) is a lightweight, interpreted, object-oriented language with first-class functions, most known as the scripting language for Web pages, but used in many non-browser environments as well such as node.js.
The JavaScript standard is ECMAScript. As of 2012, all modern browsers fully support ECMAScript 5.1. Older browsers support at least ECMAScript 3. A 6th major revision of the standard is being worked on.
A good reference to versions, references and news about JavaScript, you can find at Mozilla Developer Network.
The Document Object Model (DOM) is an API for HTML and XML documents. It provides a structural representation of the document, enabling you to modify its content and visual presentation by using a scripting language such as JavaScript. See more at Mozilla Developer Network - DOM
As every language, JavaScript has many code style guides. Maybe the most used and recommended is the Google Code Style Guide for JavaScript, but we recommend you to read the Idiomatic.js.
Nowadays the best tool to linting your JS code is the JSHint. We recommend you whanever possible to verify you code style with a Lint tool.
Too many of the classical design patterns are implemented and have uses in JavaScript and there are some JS Patterns that are exclusive.
A good way to learn about these is Addy Osmani’s open source book Learning JavaScript Design Patterns, and the links below are (in the majority) based on it.
There are some implementations of the traditional MVC Pattern and its variations in JS:
JSMentors - Mailing list for discussion of JavaScript, ECMAScript and Browser scripting.