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
// react | |
const handleChange = (fieldName) => (event) => {aveField(fieldName, event.target.value)} | |
<input type="text" onChange={handleChange('email')} ... /> |
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
getters: { | |
// ... | |
getTodoById: (state, getters) => (id) => { | |
return state.todos.find(todo => todo.id === id) }} | |
store.getters.getTodoById(2) // -> { id: 2, text: '...', done: 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
// connect | |
export default connect()(TodoApp) | |
// connect with action creators | |
import * as actionCreators from './actionCreators' | |
export default connect(null, actionCreators)(TodoApp) | |
// connect with state | |
export default connect(state => state)(TodoApp) |
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
function add(x, y) { | |
return x+y; | |
} | |
let increment = add.bind(undefined, 1); | |
console.log(increment(4) === 5); // true |
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
var curry = function(uncurried) { | |
var parameters = Array.prototype.slice.call(arguments, 1); | |
return function() { | |
return uncurried.apply(this, parameters.concat( | |
Array.prototype.slice.call(arguments, 0) | |
)); | |
}; | |
}; |
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
let greetDeeplyCurried = greeting => separator => emphasis => name => console.log(greeting + separator + name + emphasis); | |
let greetAwkwardly = greetDeeplyCurried("Hello")("...")("?"); | |
greetAwkwardly("haegul"); // Hello...haegul? | |
let sayHello = greetDeeplyCurried("Hello")(", "); | |
sayHello(".")("haegul"); // Hello, haegul. | |
let askHello = sayHello("?"); | |
askHello("haegul"); // Hello, haegul? |
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
// currying | |
let printInfo = group => name => console.log(group + ', ' + name); | |
let devGroup = printInfo('developer'); | |
devGroup('haegul'); // developer, haegul | |
devGroup('jiwon'); // developer, jiwon | |
devGroup('sungcheon'); // developer, sungcheon |
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
printInfo('developer', 'haegul'); // developer, haegul | |
printInfo('developer', 'jiwon'); // developer, jiwon | |
printInfo('developer', 'sungcheon'); // developer, sungcheon |
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
let printInfo = function(group, name){ | |
console.log(group + ', ' + name); | |
}; | |
printInfo('developer', 'haegul'); // developer, haegul |
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
let sum = x => y => x+y; | |
let sum5 = sum(5); | |
let sum12 = sum5(7); | |
console.log(sum12, sum(5)(7)); // 12 12 |