Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

A very happy way to live as a Javascript coder is to avoid the `this` keyword, in my experience. You really don't need it. Instead write this function as

    (x, y) => Math.sqrt(x*x + y*y)
That can never have any state bugs, because it's a pure function (just like you can never have type errors with a sufficiently good type system).

And you might be interested in the native JS function (since ES6) called Math.hypot. Happy hacking :-)



Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: