Skip to content

Instantly share code, notes, and snippets.

View santiago-puch-giner's full-sized avatar
💫
In an exciting new adventure

Santi Puch Giner santiago-puch-giner

💫
In an exciting new adventure
  • 08:28 (UTC +02:00)
View GitHub Profile
@santiago-puch-giner
santiago-puch-giner / promises_es6.js
Last active May 5, 2016 22:18
Promises in Javascript ES6
// Snippet for Promises (ES6)
// Create a Promise that is resolved and handle it using "then" methods
let p = new Promise( (resolve, reject) => {
setTimeout( () => {
resolve("Good to go!");
}, 1000);
});
p.then(
@santiago-puch-giner
santiago-puch-giner / filterListUnique.js
Created April 25, 2016 14:54
Filter an array of Strings, Numbers, etc. to have only the unique values
let my_array = ['Elem1', 'Elem2', 1, 2, 'Elem3', 'Elem2', 'Elem4', 1, 5];
let filtered = my_array.filter( (element, index, thisArray) => thisArray.indexOf(element) === index);
console.log(my_array);
console.log(filtered);
@santiago-puch-giner
santiago-puch-giner / filterListObjects.js
Last active September 25, 2018 23:28
Filter an array of objects to have "unique" objects with respect some of their properties. Uses new Map from ES6.
// Data
let data = [
{
name: 'John',
SSID: 1
},
{
name: 'John',
SSID: 2
},