Skip to content

Instantly share code, notes, and snippets.

@julsfelic
Created May 4, 2016 17:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save julsfelic/84ad1c7d53886e040979a5be0bf7bafb to your computer and use it in GitHub Desktop.
Save julsfelic/84ad1c7d53886e040979a5be0bf7bafb to your computer and use it in GitHub Desktop.
JavaScripting

Nodeschool.io JavaScripting

Introduction

  • No notes were taken

Variables

  • No notes were taken

Strings

  • Looks like convention in JavaScript is to use single quotes.

String Length

  • No notes were taken

Revising Strings

  • JavaScript has a .replace() method that takes two arguments. The first argument is an existing substring and the second is the string that will replace it.

Numbers

  • No notes were taken

Rounding Numbers

  • To round numbers in JavaScript we use the Math object along with the .round() method and pass it in the float we want rounded.

Number to String

  • We use the .toString() method to convert a number to a string.

If Statement

  • No notes were taken

For Loop

  • No notes were taken

Arrays

  • No notes were taken

Array Filtering

  • We use the .filter() method to filter an array based on a condition.
var filtered = numbers.filter(function(num) {
  return num % 2 === 0;
});

Accessing Array Values

  • No notes were taken

Looping Through Arrays

  • No notes were taken

Objects

  • No notes were taken

Object Properties

  • No notes were taken

Functions

  • No notes were taken

Function Arguments

  • No notes were taken

Scope

  • Scope is the set of variables, objects, and functions you have access to.
  • JavaScript has two scopes: global and local.
  • A variable that is declared outside a function definition is a global variable, and its value is accessible and modifiable throughout your program.
  • A variable that is declared inside a function definition is local. It is created and destroyed everytime the function is executed, and it cannot be accessed by any code outside the function.
  • Functions defined inside other functions, known as nested functions, have access to their parent function's scope.
  • IIFE, Immediately Invoked Function Expression, is a common pattern for creating local scopes.
(function() {
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment