Project Falcon

What Is JS?

Welcome to JavaScript (JS)! The programming language that is native to the browser environment. This is an important language to learn because no matter what Back End language is in a project, JS is going to be essential. There are some conventions that should be followed when writing JS. The first of which is naming conventions. JS uses a camel case convention. So words are broken up by using capital letters. For example:

function myFunction() { // do something } const thisIsAVariable = true;

It is possible to name things in JS with any naming conventions, but camel case is widely used.

The next topic is comments. There is a widely accepted belief that all code should be commented. While this is true, the idea behind it may be a bit abstracted. Comments should only remain in code when absolutely necessary. Removing comments should be a part of refactoring code. Comments should be able to be removed and replaced by better naming conventions in the process.

// this function should replace dashes with spaces const placeholder = (str) => { return str.split('-').join(' '); };

While this is a useful function with a useful comment, it could be replaced with proper naming.

const replaceDashesWithSpaces = (str) => { return str.split('-').join(' '); };

Even though this may seem like a small change, it is a huge upgrade in code quality. It's important to use comments when they improve readability of the code, but they should be avoided when possible. A good example of when to use comments comes from a library called Lodash. They can describe what a complex function is going to do instead of having developers search around

Data Types

Primitives

String

Number

  • NaN
  • Infinity

BigInt

Boolean

Symbol

undefined

null

Objects

  • Destructuring

Object

  • Object.keys()
  • Object.values()
  • Object.entries()

Array

Function

Date

Math

Map/WeakMap

Set/WeakSet

Operators

Math

  • +
  • -
  • *
  • /
  • %

Concatenation

  • + but with strings

Unary Operators

  • typeof
  • =

Logical Operators

  • %%
  • ||
  • ??

Ternary Operator

Variables

Keywords

Names

Values

Expressions

Conditional Logic

Loops

  • break, return, continue

While

Do While

For

switch

Functions

Scope

Declaration

function fuckOff() { // get about fucking off }

Arrow

const iAmVariable = () => { // do stuff };

Default Values for Parameters

Closures

Higher Order Functions

OOP

Classes

Constructor

Properties

Methods

Creation

Functional

Immutability

Side Effects

Pure Functions

Modules

Conclusion

Challenge

FizzBuzz without tests