Skip to content

Instantly share code, notes, and snippets.

@martypdx
Last active August 9, 2016 21:09
Show Gist options
  • Save martypdx/64ce058447af033467aa9e76608ef0ef to your computer and use it in GitHub Desktop.
Save martypdx/64ce058447af033467aa9e76608ef0ef to your computer and use it in GitHub Desktop.

control flow

  • if, else, while, for, do

functions

closures

var a = 'foo';
function b(){
	return a;
}
b();

"this" keyword

functional programming

  • array methods: .filter, .map, .reduce, .find, etc.

objects

Constuctor functions

function Foo(){}
Foo.prototype.bar = function(){}
var foo = new Foo();

Object literals

var foo = {
	bar: 'bar'
};

Objects as hashes/dictionaries

var items = {};

function add( key, value ) {
	items[key] = value;
}

function get( key ) {
	return items[key];
}

function exists( key ) {
	return !!items[key];
}

function remove( key ) {
	delete item[key];
}

Asynchronous Javascript

console.log('a');
setTimeout(function(){
    console.log('c');
}, 1000);
console.log('b');
// works in node via:
// > node name-of-this-file.js

const fs = require( 'fs' );

fs.readFile( 'package.json', ( err, file ) => {
    console.log( file.toString() );
});

ES6 (ES2015)

Fat arrows

Practice Javascript

Codewars

YDKJS

  • Scopes and Closures
  • this and Object Prototypes

Work through examples

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment