A cheat sheet for JavaScript developers

person sitting in front of computer writing in a notebook
person sitting in front of computer writing in a notebook
Photo by J. Kelly Brito on Unsplash

tl;dr

  • For arrays, use for...of (or forEach).
  • For objects, use for...in.
  • If you work with arrays and need access to indexes, use for or forEach.

for...in loop


Make your code run faster and look cleaner

Plant on a desk
Plant on a desk
Photo by Tim Chow on Unsplash.

1. Default Parameters

let sumFunctionThatMayBreak = (a, b, inconsistentParameter) => a+b+inconsistentParametersumFunctionThatMayBreak(1,39,2) // => 42
sumFunctionThatMayBreak(2,40, undefined) // => NaN


Cancel all subscriptions and asynchronous tasks in the componentWillUnmount method

Image for post
Image for post
source: pexels.com

What We’ll Build


Learn fast how to play with data and scopes in Ruby.

Image for post
Image for post
Photo by Miriam Espacio from Pexels

1. Local variables

favorite_quote = "Don't Panic."


Increase your page’s SEO and accessibility with one quick trick

Image for post
Image for post
source: pexels.com


Code construction through real-life construction

Image for post
Image for post
Photo by Yancy Min on Unsplash

Background: What are Lifecycle Methods?


Be worry-free and enjoy React Router like a pro

Image for post
Image for post
Route 66 Printed on Road from Pexels.com

Setup


How to update just one value in an array of objects in a state

Image for post
Image for post
“Red and Blue Pelikan Br 40 Eraser on White Surface” by Pixabay
state = {
todos: [
{id: 1,
title: "Eat breakfast",
completed: false},
{id: 2,
title: "Make bed",
completed: false}
]
}

Step 1: Find the element


“A man, a plan, a canal — Panama!” palindrome // true

Image for post
Image for post
Photo by Evgeny Tchebotarev from Pexels


Organize your process, write clean code, and test like a boss

Image for post
Image for post
Photo by K. Mitch Hodge on Unsplash

Step 1: Read the HTML File

Sylwia Vargas

I teach React, Redux, JavaScript, Ruby, Rails at Flatiron School and Yale University | Follow me: https://twitter.com/sylwiavargas

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store