4.17 out of 5
33 reviews on Udemy

Mastering Clean Code in JavaScript

Learning the JavaScript framework is good and cleaner JavaScript is even better
Packt Publishing
248 students enrolled
English [Auto-generated]
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

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.

Clean Code with JavaScript

The Course Overview

This video provides an overview of the entire course.

Clean Variables

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

Lexical Scope and let

Developers often have mistaken ideas surrounding lexical scope.

Clean Functions

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

All about this

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

Clean Objects and Classes

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

Using a linter

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

Clean Code with Functional Programming

Introduction to Functional Programming
Some viewers may not know what is functional programming.
Writing a Pure Function

Pure functions are fundamental to functional programming.

Object.assign and the Spread Operator

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

Forget the Loop with Map and ForEach

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

Reducing an Array
Map and forEach are good only for certain cases.
Filtering an Array
Sometimes you need to only accept some of the items from an array.

Modules in JavaScript

Why Modules

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

The Module Pattern

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

The Node Package Manager

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

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

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

Tree-Shaking with Webpack

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

Design Patterns and Principles

The Single Responsibility Principle

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

The Open/Closed Principle

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

The Liskov Substitution Principle

The Liskov substitution principle is often overlooked in JavaScript apps.

The Interface Segregation Principle

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

The Dependency Inversion Principle

Dependency Injection can really transform your applications to something great.

The Singleton Pattern
Sometimes you need to have a single instance of something available in your code.
The Observer Pattern
The observer pattern is useful when you want to watch properties.
The Strategy Pattern
Sometimes you want to hot-swap similar algorithms at runtime.


Introduction to Unit Testing

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

Installing and Using Jasmine
Simple unit tests are only good for simple problems and small codebases.
Test Driven Development

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

Making the Tests Pass

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

Error Handling

Error Handling Best Practices
Error handling plays a very important part in software engineering.
Catching Errors from Promises

Promise rejections are much different than simple errors.

An Error Handler with Strategy

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

Error Management is not just about showing nice messages to the user.
You can view and review the lecture materials indefinitely, like an on-demand channel.
Definitely! If you have an internet connection, courses on Udemy are available on any device at any time. If you don't have an internet connection, some instructors also let their students download course lectures. That's up to the instructor though, so make sure you get on their good side!
4.2 out of 5
33 Ratings

Detailed Rating

Stars 5
Stars 4
Stars 3
Stars 2
Stars 1
30-Day Money-Back Guarantee


5 hours on-demand video
Full lifetime access
Access on mobile and TV
Certificate of Completion