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* myFirstGenerator(a) { | |
console.log('Before yielding'); | |
let b = 5 + (yield(a + 5)); | |
console.log('After yielding'); | |
return b; | |
} |
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* secondGenerator(a) { | |
yield (a + 1); | |
yield (a + 2); | |
yield (a + 3); | |
} | |
function* firstGenerator(a) { | |
yield a; | |
yield* secondGenerator(a); | |
yield (a + 10); |
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
handleClick(e) { | |
console.log('Clicked', e); | |
} | |
render() { | |
<button onClick={this.handleClick.bind(this)}></button> | |
} |
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
handleClick(param, e) { | |
console.log('Parameter', param); | |
console.log('Event', e); | |
} | |
render() { | |
<button onClick={this.handleClick.bind(this, 'Parameter')}></button> | |
} |
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
class MyComponent extends React.Component { | |
constructor() { | |
super(); | |
this.handleClick = this.handleClick.bind(this, 'Parameter'); | |
} | |
handleClick(param, e) { | |
console.log('Parameter', param); | |
console.log('Event', e); |
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
handleClick(e) { | |
console.log('Event', e); | |
} | |
render() { | |
<button onClick={(e) => this.handleClick(e)}></button> | |
} |
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
handleClick(param, e) { | |
console.log('Parameter', param); | |
console.log('Event', e); | |
} | |
render() { | |
<button onClick={(e) => this.handleClick(param, e)}></button> | |
} |
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
handleClick = (e) => { | |
console.log('Event', e); | |
} | |
render() { | |
<button onClick={this.handleClick}></button> | |
} |
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
handleClick = (param) => (e) => { | |
console.log('Event', e); | |
console.log('Parameter', param); | |
} | |
render() { | |
<button onClick={this.handleClick('Parameter')}></button> | |
} |
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 myTag = (literals, name) => { | |
console.log('Literals', literals); //Output -> Literals [ 'Hello ', '!' ] | |
console.log('Interpolation', name); //Output -> Interpolation Steve | |
return 'Result from myTag'; | |
}; | |
const name = 'Steve'; | |
const result = myTag `Hello ${name}!`; |
OlderNewer