DEV Community


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

rsa profile image
Ranieri Althoff

Your example of the switch wouldn't work, you are assigning to a constant variable. I consider declaring without defining an issue, and would rather split the switch to a separate function (e.g. getFontWeight) and create the variable with const fontWeight = getFontWeight(value). It's cleaner and better to test.

Thread Thread
devmount profile image
Andreas Author

My bad, thanks for pointing out 👏🏻 I updated the example code. Totally agree with you about the separate function, nevertheless I just used let to keep things simple.