JavaScript parseInt(...) is BROKEN

  Рет қаралды 17,990

Conner Ardman

18 күн бұрын

From this quiz: jsisweird.com/
Prepping for your frontend interviews? Use code "conner" for a discount on my product FrontendExpert:
www.frontendexpert.io/conner
🎬 TikTok: tiktok.com/@connerardman
💼 LinkedIn: www.linkedin.com/in/connerardman
💻 Video/Coding Gear (affiliate): www.amazon.com/shop/connerardman
Business/brands 👉 youtube@connerardman.com

Пікірлер: 30
@blackandwhitegamingproduct7356
@blackandwhitegamingproduct7356 18 күн бұрын
JavaScript “your website only needs to function correctly. Don’t worry about how we got here”
@darknight3613
@darknight3613 16 күн бұрын
It doesnt function correctly tho
@XxX__GAMER__XxX
@XxX__GAMER__XxX 18 күн бұрын
JavaScript feels like a language made by people who once heard about programming while doing something totally unrelated. It's a wonder the Internet runs as well as it does lol.
@techkid10194
@techkid10194 18 күн бұрын
The creater himself said it was a rushed project and under funded, it was called mocha before there's an interview
@ward7576
@ward7576 18 күн бұрын
Sounds like one of those quizzes that you are given once you want to join a company - for them to test your knowledge and they give you obscure sh..t like this thinking it's a good way to test if you'll be able to later on style some forms differently and sit in two 1 hour meetings every day adding nothing.
@CShellStudio
@CShellStudio 18 күн бұрын
What about the other ones that were 5e^-x that it showed returned 0?
@Sims_it
@Sims_it 9 күн бұрын
It probably formats it like that only after 6 decimals, hence the other ones would be converted to a string of "0.000005", and not the exponent notation.
@burretploof
@burretploof 18 күн бұрын
I've worked with JS so much that I intuitively said it's going to be 5 when I saw the question 😂
@afxcode
@afxcode 14 күн бұрын
is that a "sixth sense" kind of thing?
@sohaibaljarih
@sohaibaljarih 18 күн бұрын
I think you need to use the second parameter of the partseIn and put a 10 to deal with it as a decimal, and I think the result in the video is for parsing the number one, but not sure.
@eclipsesword777
@eclipsesword777 15 күн бұрын
yes you are right
@MrDragos360
@MrDragos360 11 күн бұрын
If I will ever held hiring interview this will be a question 😂😂😂
@casperhansen826
@casperhansen826 18 күн бұрын
I use typescript so I don't have to worry about javascript! What? Typescript is Javascript with types?
@Easymoney1112
@Easymoney1112 18 күн бұрын
Maybe it tracks the leading zeros if given a second argument?
@nRGM7-or9se
@nRGM7-or9se 13 күн бұрын
Welcome to JS !
@afridiahmed_
@afridiahmed_ 10 күн бұрын
JavaScript: Let's confuse nerds🤡
@mangadi3859
@mangadi3859 17 күн бұрын
i love js. but that was weird.
@goldenbananas1389
@goldenbananas1389 18 күн бұрын
It converts to a string first? That is so stupid.
@nigh_anxiety
@nigh_anxiety 18 күн бұрын
The function is defined as taking a string and a radix, parseInt(string, radix=10). The main issue is that for some reason JS automatically converts those small floating point values close to 0 to exponential notation, but it allows higher precision if the leading digit isn't 0. For example: 1.000000000000005 is fine, but 0.0000005 becomes 5e-7. You can use the Number.toFixed(precision) method to force it to remain in decimal form, but you have to do something like: x=0.0000005 y=parseInt(x.toFixed(String(x).slice(String(x).length-1))) console.log(y) # outputs 0
@NoName-1337
@NoName-1337 18 күн бұрын
This isn't stupid. Js has implicit and dynamic typing. When a function is defined as parseInt(string, ...), and you throw a number into it, what should happen? Yes, it tryes to implicitly convert the number into a string, so the property gets, what it wants.
@WebEyeAlissa
@WebEyeAlissa 11 күн бұрын
Can we collaborate? We have a great app that would be perfect for your page.
@pulserudeus7968
@pulserudeus7968 15 күн бұрын
why javascript???
@britongusff120
@britongusff120 18 күн бұрын
Javascript 😎😎😎🤡
@69k_gold
@69k_gold 14 күн бұрын
Ah yes, people who don't read the STL docs come and base their entire understanding on one example. Just because the question maker passed a float, doesn't make the argument type float, it's a string. This function converts strings to ints. Even passing a string format of a float is an invalid argument
@sid.h
@sid.h 13 күн бұрын
Which is why we have types and typechecks, and not bumblebees and bumbleboos for programming.
@user-rj1gs4yn8r
@user-rj1gs4yn8r 18 күн бұрын
Who would call parseInt when you already have a number? Just convert to int, don't parse.
@davea136
@davea136 18 күн бұрын
"parsing it until it is not an int" instead of throwing an exception or returning an error for the string not being an int, as any sane programming langauge would do. There is no bottom to the layers of shittified assholery in Javascript.
@urbanski
@urbanski 18 күн бұрын
It kiiiiind of makes sense if you’re mostly thinking of a scenario where you want to handle parsing a number with a decimal and have it truncate it to everything before the decimal point. But then you remember some cultures use commas instead and you’re being lazy so you just say screw it, look for the first non-numeric character and stop, and you don’t foresee JavaScript somehow evolving into the scripting backbone of the modern internet.
@urbanski
@urbanski 18 күн бұрын
But, to your point- this is why it’s insane that JavaScript is somehow the scripting backbone of the modern internet.
Khóa ly biệt
01:00
Đào Nguyễn Ánh - Hữu Hưng
Рет қаралды 21 МЛН
Luck Decides My Future Again 🍀🍀🍀 #katebrush #shorts
00:19
Kate Brush
Рет қаралды 8 МЛН
I CAN’T BELIEVE I LOST 😱
00:46
Topper Guild
Рет қаралды 70 МЛН
Жайдарман | Туған күн 2024 | Алматы
2:22:55
Jaidarman OFFICIAL / JCI
Рет қаралды 1,4 МЛН
Simple maintenance. #leddisplay #ledscreen #ledwall #ledmodule #ledinstallation
0:19
LED Screen Factory-EagerLED
Рет қаралды 9 МЛН
Ультрабюджетная игровая мышь? 💀
1:00
iPhone 12 socket cleaning #fixit
0:30
Tamar DB (mt)
Рет қаралды 55 МЛН