DEV Community

Discussion on: JavaScript Security 101

Collapse
 
kais_blog profile image
Kai

Thanks for your post! Some of the aforementioned threats are handled if you are using TypeScript.

Also, there's something I've noticed:

From your calculatingStuffv2 function:

if (!num) {
  return new Error('Not a number!')
}
Enter fullscreen mode Exit fullscreen mode

You can't use num = 0 here. However, 0 is a valid number. Besides, you could still use Infinity. Which is a valid number in my opinion. Better to check for a defined minimum and maximum then.

Collapse
 
charlottebrf_99 profile image
Charlotte Fereday

Thanks for the observation, that's a great point. I'll do some more experiments :)