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 case to indicate a module's default export type

Use case to indicate a module's default export type - JavaScript Tutorial

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

Start my 1-month free trial

Use case to indicate a module's default export type

- [Instructor] Consistent case usage when you create names in your code can help you and other developers identify what you're working with without needing to dig into the code and examine what a name refers to. A commonly adopted best practice is to use camelCase for function in variable names and PascalCase for constructors and classes. This practice is commonly applied to default module exports as well. And it's even more useful in this situation. It lets you tell the difference at a glance between two broad categories of what a module might be exporting. In the start code for this video in app.js, I'm importing the distance module from distanceTo.js and passing values from userPrefs and testLocation to the distanceTo function to calculate a distance. My distanceTo file, includes a single function and that's default exported using camelCase. I'm already using camelCase for distanceTo because that's my default for…

Contents