Rediscover JavaScript

Brief History

Origin

Brief History

Names

Today

Versions

Everywhere

Coding Style Guide

Consistent code, even when written by a team, should look like one person wrote it.

Addy Osmani

Coding Style Guide

Based on idiomatic.js but with less whitespace inside parenthesis.

Coding Style Guide

Coding Style Guide

Coding Style Guide

Constructor Functions

Coding Style Guide

Coding Style Guide

Coding Style Guide

Naming

Always use meaningful names. An exception are commonly used names as conventions (i with for loops, e for events in handlers, err for errors in try/catch)

Coding Style Guide

Comments

IIFEs

Immediately-invoked function expressions are a common pattern used to control variable scope and avoid polluting the global namespace.

IIFEs

They are also useful for writing modular code and support importing globals via parameters passed during the invocation.

Strict Mode

Strict mode enables a stricter variant of JavaScript that prevents unsafe statements and common mistakes from being made.

Strict Mode

Strict Mode

Prototypal Inheritance

JavaScript is an object-oriented language that uses prototypal inheritance.

From MDN:
"Each object has an internal link to another object called its prototype. That prototype object has a prototype of its own, and so on until an object is reached with null as its prototype. null, by definition, has no prototype, and acts as the final link in this prototype chain."

Prototypal Inheritance

The Object.create method can be used to make new objects which prototype is the object passed as the first parameter.

Prototypal Inheritance

JavaScript also supports a form of "classical" inheritance through constructor functions.

The Module Pattern

The Module Pattern

Some Libraries & Tools

Thanks!

#