Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
theuser47814yHaha, Number("\n") == 0. Good to know I guess.
Edit: wait, I somehow mixed up minus and plus (minus will do implicit number conversion). Can you show the code? I would be interested in inspecting how that happened -
@theuser it was litturally string.replace(/\n/g,+"\n"+CONST); and +"\n" is changed to 0.
I was making a debugging/ testing tool and wanted a make the start of each line nice. -
@LavaTheif I just noticed that +'\n' gets converted to 0 but +'a' into NaN
What the fuck is even happening -
theuser47814y@LavaTheif Ah so you did convert it do a number. I haven't been messing around with newlines before, but just like empty string and whitespace, a newline is perceived as "nothing".
Number("") == 0
Number(" ") == 0
Number("\n") == 0
Number(null) == 0
Number(undefined) == NaN -
theuser47814y@pxeger Static vs dynamic, the difference is knowing when you've ballsed it up pretty much.
-
Bubbles66124yWhat?? This is the kind of shit that makes me wish I didn’t know JS and that it would get replaced by something else already
Just spent 20 mins trying to figure out why new lines weren't printing and why random '0's were in the text.
Turns out I was replacing with +"\n" which JavaScript converts to a 0.
Fuck this
rant