DEV Community

Discussion on: 8 neat Javascript tricks you didn't know in 4 minutes.

Collapse
 
lloydfranklinsmith profile image
Lloyd Franklin Smith

It's just unnecessarily difficult to tell what you are trying to do which makes the code less maintainable with parseInt I can look at the line and immediately know you meant to receive a number with the + method you might have wanted a string and just made a mistake and forgot whatever should have come before.

Thread Thread
 
blessinghirwa profile image
Blessing Hirwa

The reason why you see parseInt and know what it's doing is because you're familiar with it, so by the time many people become familiar with it then they'll easily recognize it, but I think this ones are also obvious by the way. But anyway it's totally fine, thank you for the feedback 😁

Thread Thread
 
blessinghirwa profile image
Blessing Hirwa

This makes sense. At this point then one has to be more careful.

Thread Thread
 
jkettmann profile image
Johannes Kettmann

I would disagree. parseInt is much more explicit because it does what it says. It parses an integer.

Thread Thread
 
blessinghirwa profile image
Blessing Hirwa

I agree. But all can be used.

Some comments have been hidden by the post's author - find out more