// Noobs:letnum=15;lets=num.toString();// number to stringletn=Number(s);// string to number// Pro:letnum=15;lets=num+"";// number to stringletn=+s;// string to number
Sorry, but clever != pro. The "Noob" version much better reveals the intent of the code.
I wouldn't say better as it reduces the readability and maintainability of the code a lot. Having a language with strict type casting may seem a hassle for some, but it saves you hours of debugging in the long run. It was one of the significant reasons for the development of TypeScript and as a goal for both PHP 7 and Python 4.
Sorry, but I have to strongly disagree. Please don't make people think it's better to complicate things. The Noob version is actually a Pro especially in big projects. I already wrote it here dev.to/misobelica/comment/15b21
JS is not the best language even without these quirks. We should know them but consider them a very sad code smell and not a Pro version.
I'm sorry sir. When i will post again something related to this i will surely keep this in mind. Currently i'm writing through my phone so it will be hard for me to do. I'm sorry once again
Preact - Next.js - Deno - SSR - SSG 💻
Open source 📂
Machine learning 🤖
Books 📖
Sport 🏃♂️
Nature 🌱
Focus on being useful. I contribute AMAP to the OSS community. Love learning by doing.
Preact - Next.js - Deno - SSR - SSG 💻
Open source 📂
Machine learning 🤖
Books 📖
Sport 🏃♂️
Nature 🌱
Focus on being useful. I contribute AMAP to the OSS community. Love learning by doing.
Sorry, but clever != pro. The "Noob" version much better reveals the intent of the code.
I agree. But you know the pro version is better when you know many things about JS and doing big projects. I too had some doubt when writing this.
It is not readable and maintainable in the long run.
Agree.
I wouldn't say better as it reduces the readability and maintainability of the code a lot. Having a language with strict type casting may seem a hassle for some, but it saves you hours of debugging in the long run. It was one of the significant reasons for the development of TypeScript and as a goal for both PHP 7 and Python 4.
People write codes with their read comfort ability.
Pretty much the #1 rule when learning programming is to not only write for yourself but with future coders and teammates in mind.
Sorry, but I have to strongly disagree. Please don't make people think it's better to complicate things. The Noob version is actually a Pro especially in big projects. I already wrote it here dev.to/misobelica/comment/15b21
JS is not the best language even without these quirks. We should know them but consider them a very sad code smell and not a Pro version.
I'm sorry sir. When i will post again something related to this i will surely keep this in mind. Currently i'm writing through my phone so it will be hard for me to do. I'm sorry once again
I would never approve a PR with something like that.
was going to say that too 😉
I am not so cool with the "pro" code, def not advisable for team based projects
Same for
a^123
is not very clean IMO. Maybe a better one will beif(a !== 123)
IMHO
Also we should think this is something that someone who comes from another Programming Language won't understand easily, just for saving 1 character
And it's not correct for decimal numbers.
Much better to use the
!==
operator.