This file contains hidden or 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 person = { score: 25 }; | |
let newScore = person.score | |
|> double | |
|> add(7, ?) | |
|> boundScore(0, 100, ?); | |
newScore //=> 57 |
This file contains hidden or 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 user = url | |
|> api.get | |
|> await | |
|> (r => r.json()) | |
|> await | |
|> (j => j.data.user); |
This file contains hidden or 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
Show hidden characters
{ | |
"plugins":[ | |
["@babel/plugin-proposal-pipeline-operator", { "proposal": "minimal"}], | |
["@babel/plugin-proposal-optional-chaining", { "loose": false }], | |
] | |
} |
This file contains hidden or 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 = { | |
foo: { | |
bar: { | |
baz: 42, | |
}, | |
}, | |
}; | |
const baz = obj?.foo?.bar?.baz; // 42 | |
const safe = obj?.qux?.baz; // undefined | |
const fooValue = myForm.querySelector('input[name=foo]')?.value |
This file contains hidden or 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
if (myForm.checkValidity?.() === false) { | |
return; | |
} |
This file contains hidden or 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
{ | |
"plugins":[ | |
["@babel/plugin-proposal-pipeline-operator", { "proposal": "minimal"}], | |
["@babel/plugin-proposal-optional-chaining", { "loose": false }], | |
"@babel/plugin-proposal-logical-assignment-operators" | |
] | |
} |
This file contains hidden or 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 a | |
let b = 'foo' | |
a ||= b // a -> 'foo' | |
let c = 'bar' | |
let d = 'ddd' | |
c &&= d // c -> 'ddd' |
This file contains hidden or 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
{ | |
"plugins":[ | |
["@babel/plugin-proposal-pipeline-operator", { "proposal": "minimal"}], | |
["@babel/plugin-proposal-optional-chaining", { "loose": false }], | |
"@babel/plugin-proposal-logical-assignment-operators", | |
"@babel/plugin-proposal-do-expressions" | |
] | |
} |
This file contains hidden or 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 f = () => 10 | |
let x = do { | |
let tmp = f(); | |
tmp * tmp + 1 | |
}; // x -> 101 |
This file contains hidden or 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 getColoredComponent = color => { | |
if(color === 'blue') { return <BlueComponent/>; } | |
if(color === 'red') { return <RedComponent/>; } | |
if(color === 'green') { return <GreenComponent/>; } | |
} | |
const Component = props => | |
<div className='myComponent'> | |
{getColoredComponent()} | |
</div> | |
; |