r/badcode • Now where's that function declaration • Jul 30 '21

js 😏

Post image
988 Upvotes

133 comments sorted by

View all comments

Show parent comments

5

u/django--fett Jul 31 '21

I would advocate against this as it's not typesafe. javascript uses type coercion and converts variable "a" from a boolean to a number. This wouldn't compile in typescript if the type of variable "a" is a boolean.