Skip to content

Instantly share code, notes, and snippets.

@sewerynkalemba
Created December 3, 2020 17:36
Show Gist options
  • Save sewerynkalemba/3dc58a310cb57f0b5bb31ce6ed9a5cc4 to your computer and use it in GitHub Desktop.
Save sewerynkalemba/3dc58a310cb57f0b5bb31ce6ed9a5cc4 to your computer and use it in GitHub Desktop.
// const obj = {x: 3.6, y: 7.8}
// makeCalculation(obj)
function makeCalculation({x, y: d, z = 4}) {
return Math.floor((x + d + z) / 3)
}
// to jest to samo, co:
function makeCalculation(obj) {
const {x, y: d, z = 4} = obj
return Math.floor((x + d + z) / 3)
}
// co równa się temu:
function makeCalculation(obj) {
const x = obj.x
const d = obj.y
const z = obj.z === undefined ? 4 : obj.z
return Math.floor((x + d + z) / 3)
}
// w Reactcie:
function UserGitHubImg({username = 'ghost', ...props}) {
return <img src={`https://github.com/${username}.png`} {...props} />
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment