Skip to content

Instantly share code, notes, and snippets.

View SakoMe's full-sized avatar
😎

Sarkis M SakoMe

😎
  • Venice Beach, Ca
View GitHub Profile
@SakoMe
SakoMe / ES5.js
Created July 5, 2017 01:57
ES5 vs ES6 constructor functions
'use strict';
/**
* Shape class.
*
* @constructor
* @param {String} id - The id.
* @param {Number} x - The x coordinate.
* @param {Number} y - The y coordinate.
*/
// Functional JS to flatten an array...
const flatten = (array) => {
return array.reduce((flat, toFlatten) => {
return flat.concat(Array.isArray(toFlatten) ? flatten(toFlatten) : toFlatten);
}, []);
}
console.log(flatten([[1,2,[3]],4]));
@SakoMe
SakoMe / promise-vs-async-await.js
Last active June 14, 2017 01:52
Promises vs async / await...
//SET UP
const users = [{
id: 1,
name: 'Bob',
schoolId: 101
}, {
id: 2,
name: 'Jane',
schoolId: 999