Mastering Clean Code in JavaScript
4.2 (94 ratings)
Course Ratings are calculated from individual students’ ratings and a variety of other signals, like age of rating and reliability, to ensure that they reflect course quality fairly and accurately.
615 students enrolled

Mastering Clean Code in JavaScript

Learning the JavaScript framework is good and cleaner JavaScript is even better
4.2 (94 ratings)
Course Ratings are calculated from individual students’ ratings and a variety of other signals, like age of rating and reliability, to ensure that they reflect course quality fairly and accurately.
615 students enrolled
Created by Packt Publishing
Last updated 3/2018
English [Auto-generated]
Current price: $80.99 Original price: $124.99 Discount: 35% off
15 hours left at this price!
30-Day Money-Back Guarantee
This course includes
  • 4.5 hours on-demand video
  • 1 downloadable resource
  • Full lifetime access
  • Access on mobile and TV
  • Certificate of Completion
Training 5 or more people?

Get your team access to 4,000+ top Udemy courses anytime, anywhere.

Try Udemy for Business
What you'll learn
  • Structure better code in modules with ease
  • Write pure functions, avoid side-effects, and go functional
  • Explore design patterns and practices and how to use them
  • Get familiar with unit testing
  • Proper error handling in JavaScript
Course content
Expand all 36 lectures 04:41:13
+ Clean Code with JavaScript
7 lectures 01:03:58

This video provides an overview of the entire course.

Preview 03:07

We have to begin the journey to cleaner code from somewhere and variables is the perfect place to start.

Clean Variables

Developers often have mistaken ideas surrounding lexical scope.

Lexical Scope and let

Functions form the majority of a developer’s JavaScript code. Functions need to be as clean as possible.

Clean Functions

The this keyword is a common source of bugs for developers who often produce bad code because of it.

All about this

The viewer would benefit from a few tips on how to more effectively work with objects and ES6 classes.

Clean Objects and Classes

JavaScript code can often become chaotic, especially in big projects.

Using a linter
+ Clean Code with Functional Programming
6 lectures 31:34
Some viewers may not know what is functional programming.
Preview 04:49

Pure functions are fundamental to functional programming.

Writing a Pure Function

ES6 came with some really nice features that help you transform your code with functional programming.

Object.assign and the Spread Operator

Using a typical for loop is a thing of the past in JavaScript.

Forget the Loop with Map and ForEach
Map and forEach are good only for certain cases.
Reducing an Array
Sometimes you need to only accept some of the items from an array.
Filtering an Array
+ Modules in JavaScript
7 lectures 44:15

JavaScript has evolved massively during the last decade and modules have been an integral part to this evolution.

Preview 06:21

All module definitions like CommonJS and AMD have their roots in the module pattern.

The Module Pattern

Nearly all modern JavaScript applications make use of npm. There cannot be clean code without npm.

The Node Package Manager
CommonJS is the module definition most widely adopted by NodeJS projects.

AMD came as a solution to the synchronous nature of CommonJS not being optimal for a browser environment.


ES6 modules are the solution to multiple problems and come time they will be the norm in most JavaScript projects.

ES6 Modules

ES6 modules in combination with webpack 3 and the uglifyJS plugin offer the ability to remove unused code from the final bundle.

Tree-Shaking with Webpack
+ Design Patterns and Principles
8 lectures 01:19:59

Classes should be designed to do one thing. This is not often the case in JavaScript applications.

Preview 13:37

JavaScript functions, modules and classes should be closed to modification but open to extension.

The Open/Closed Principle

The Liskov substitution principle is often overlooked in JavaScript apps.

The Liskov Substitution Principle

An interface should not force a class to implement methods and functionality that it does not need.

The Interface Segregation Principle

Dependency Injection can really transform your applications to something great.

The Dependency Inversion Principle
Sometimes you need to have a single instance of something available in your code.
The Singleton Pattern
The observer pattern is useful when you want to watch properties.
The Observer Pattern
Sometimes you want to hot-swap similar algorithms at runtime.
The Strategy Pattern
+ Testing
4 lectures 36:01

Beginning the section, the viewer needs to be prepared for the heavy stuff that will follow regarding unit testing.

Preview 06:28
Simple unit tests are only good for simple problems and small codebases.
Installing and Using Jasmine

To make the most out of unit tests you need to incorporate them into your workflow.

Test Driven Development

After the red part of TDD you are ready to implement the functionality until all tests are passed.

Making the Tests Pass
+ Error Handling
4 lectures 25:26
Error handling plays a very important part in software engineering.
Preview 07:19

Promise rejections are much different than simple errors.

Catching Errors from Promises

The error handler we built in a previous section was a nice start.

An Error Handler with Strategy
Error Management is not just about showing nice messages to the user.
  • Prior JavaScript programming knowledge is essential

Alongside HTML and CSS, JavaScript is one of the three core technologies of World Wide Web content production. You can write terrible code in any language, but if you wanted to try to write terrible code that works, JavaScript would be your language of choice.

In this course, you will learn various concepts and techniques, essential principles, patterns, and practices for writing clean code in JavaScript. You will be introduced to some general guidelines on how to better structure your JavaScript code. You will then learn about clean code best practices while working with variables, functions objects, and the latest ES6 classes. Next, you will discover functional programming, how to write pure functions, and how to use built-in functional methods. You will then move on to modular JavaScript and explore the various ways you can structure your modules. After that, you will master various design patterns and programming principles. Unit testing is very important and you will learn to do this with Jasmine and Karma, to make handling errors easy.

By the end of the course, you will have learned to learn clean coding with functional programming, explored various modules in JavaScript, and designed patterns and principles. Overall you will learn to write better code with improved readability.

About the Author :

Dimitris Loukas is a software engineer currently writing Single Page Applications and using the latest version of JavaScript with Aurelia and Angular for a trading software firm. He is also finishing his Computer Science studies at the University of Athens. He has worked for two start-ups in the past, is active in the open source community, and loves taking up small side projects. He has mastered Angular, Aurelia, and VueJS and is now interested in entering the ReactJS world. He is fascinated by modern JavaScript and where the web is going.

Who this course is for:
  • JavaScript developers