DEV Community

loading...

Discussion on: PHP 8 features I wish also existed in JavaScript

Collapse
garretharp profile image
Garret • Edited

1:

function foo ({ a, b, c, d, e, f }) {
    // do stuff
}

foo({ f: false })
Enter fullscreen mode Exit fullscreen mode

2:

const weightList = {
    100: "Super Thin",
    300: "Thin",
    ...
}

const fontWeight = weightList[weight]
Enter fullscreen mode Exit fullscreen mode

3:

(Requires Typescript or ESNext)

const country = session?.user?.getAddress()?.country
Enter fullscreen mode Exit fullscreen mode