Created
July 22, 2017 13:47
-
-
Save HomoEfficio/e90b1166517fa84b799a670638e9b3a4 to your computer and use it in GitHub Desktop.
usage-of-reduce()-in-javascript
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
render() { | |
this._parent.innerHTML = ''; | |
[ | |
[ | |
DOMRenderer.el('input', 'type', 'text'), | |
DOMRenderer.el('button', 'innerHTML', 'add', 'addEventListener', ['click', e => this.add(new Task(e.target.previousSibling.value))]) | |
].reduce((p, c) => (p.appendChild(c), p), DOMRenderer.el('section')), | |
DOMRenderer.el('hr'), | |
this._data.list.reduce((p, c) => (p.appendChild( | |
[ | |
DOMRenderer.el('h2', '@display', 'inline', 'innerHTML', c.name), | |
DOMRenderer.el('button', 'innerHTML', 'remove', 'addEventListener', ['click', e => this.remove(c)]) | |
].reduce((p, c) => (p.appendChild(c), p), DOMRenderer.el('section')) | |
), p), DOMRenderer.el('section')) | |
].reduce((p, c) => (p.appendChild(c), p), this._parent); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
코드 보고 있으니 눈이 빙빙 도는군요 @.@;