This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const webpackBuilds = { | |
awesomeBundle: { | |
files: ['js/src/awesome/app.js'], | |
outputName: 'awesome/app.min.js', // compiles to js/compiled/awesome/app.min.js | |
}, | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const obj = { | |
name: 'Kuro', | |
species: 'dog', | |
id: '135', | |
country: 'Australia' | |
}; | |
const reject = (...rejectedKeys) => obj => | |
// convert the keys of the object to an array and reduce over them |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// our example array to work with | |
const myArr = [{ | |
name: 'bob', | |
id: 5, | |
}, { | |
name: 'scott', | |
id: 4, | |
}, { | |
name: 'matt', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const renderSample = text => { | |
const div = document.createElement('div'); | |
div.className = 'my-shiny-div'; | |
const textNode = document.createTextNode(text); | |
div.appendChild(textNode); | |
return div; | |
} | |
const titles = ['hello', 'yep', 'nope', 'maybe', 'goodbye']; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const first = () => Promise.resolve('this'); | |
const second = res => Promise.resolve(`${res} is`); | |
const third = res => Promise.resolve(`${res} a sequence`); | |
const somePromises = [ | |
first, | |
second, | |
third | |
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Make our function useful within a mapping function: | |
const prefix = prefix => value => `${prefix}${value}`; | |
// our function takes a prefix string, then returns a function which takes value, | |
// which then returns a string with the prefix and value together. | |
const animals = ['dog', 'cat', 'bird', 'giraffe']; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Imagine we had an event listener that would control toggling a visibility class of an element | |
**/ | |
const toggleVisibleClass = event => { | |
console.log(event.target.value + 'changed'); | |
someTarget.classList.toggle('is-visible'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Imagine we had an event listener that would control toggling a visibility class of an element | |
const toggleVisibleClass = event => { | |
console.log(event.target.value + 'changed'); | |
someTarget.classList.toggle('is-visible'); | |
} | |
checkbox.addEventListener('change', toggleVisible, false); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// our getValue function from earlier | |
const getValue = property => obj => obj && obj[property]; | |
// Lets use a pipe function to combine the two functions: | |
const pipe = (func1, func2) => (...args) => func2(func1(...args)); | |
// our list of user objects | |
const users = [{ | |
name: 'sarah', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const valueEquals = value => comparison => value === comparison; | |
const people = ['bob', 'sarah', 'kate', 'john', 'steve', 'stu', 'sam']; | |
people.filter(valueEquals('sarah')); | |
// returns an array value where any value equals sarah | |
people.find(valueEquals('bob')); | |
// returns the first value it finds ‘bob’ |
NewerOlder