From the course: JavaScript: Best Practices for Functions and Classes

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Use PascalCase for naming classes and constructors

Use PascalCase for naming classes and constructors - JavaScript Tutorial

From the course: JavaScript: Best Practices for Functions and Classes

Start my 1-month free trial

Use PascalCase for naming classes and constructors

- [Instructor] There are a few different standards for naming things in JavaScript. For instance, when you catenate words together to make a name, you take out the spaces and capitalize the first letter of every word but the first. That's camelCase in a nutshell. By convention, most JavaScript names don't start with a capital letter, but there's one exception. When you're naming a class or a constructor, you start the name with a capital letter. This is known as PascalCase. Now a JavaScript parser doesn't treat a name with an initial cap any different from any other name. That capital letter doesn't have syntactical meaning in the language. But this convention makes your code easier to read by making it clear that the code you're assigning the name to is intended for use in creating new objects. In the code for this video, I have a class followed by a statement that calls the class to create a new cart object. I…

Contents