Тёмный

5 Things I Hate About JavaScript 

ThePrimeagen
Подписаться 413 тыс.
Просмотров 251 тыс.
50% 1

Опубликовано:

 

28 сен 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 830   
@ThePrimeagen
@ThePrimeagen 2 года назад
I didn't include this, bind, type coercion, let dead zones, or any typical "i hate js." I also didn't include Dates because I am convinced that when it was conceived it was considered the best way to handle dates (have you seen other languages in the mid 90s? It was a literal copy of another library at tha time) But the items I included are truly awful items that are not found in other languages (that i know of)
@oskrm
@oskrm 2 года назад
This list is a unique one. Not just using the same broken CD.
@itspravas
@itspravas 2 года назад
Hello Mr @ThePrimeagent, Big Fan of your twitch stream. What is the green that you're using ? Or it is your wall painted in that color.
@DBZM1k3
@DBZM1k3 2 года назад
I think the forEach case is acceptable because sometimes you just want to iterate over the value in some iterable type. So having it value, key allows for key to be ignored entirely giving (val) => {}; Doing it the other way is more complicated to solve for.
@beriu3512
@beriu3512 2 года назад
I just read up on `let dead zones` what a peculiar thing, I've never stumbled upon it, and I'm still confused on how someone might reach that edgecase
@moodynoob
@moodynoob 2 года назад
Thank you for not using the same lame examples people often use!
@alangamer50
@alangamer50 Год назад
as Fireship once said: 'JS is a language used exclusively to build things it's not supposed to'
@AEStolfo
@AEStolfo Год назад
48 likes and 0 comments? lemme fix it. ...btw fireship rules
@dannyarcher6370
@dannyarcher6370 5 месяцев назад
Right from the very beginning.
@JuanPablodelaTorre
@JuanPablodelaTorre Год назад
“Any application that can be written in JavaScript will, eventually, be written in JavaScript.” - Jeff Atwood, founder of Stack Overflow, in 2007
@leetaeryeo5269
@leetaeryeo5269 2 года назад
5:36 This leads to one of my hot takes. Javascript is just the BASIC of the 2010-2020s. It's an approachable entry point for new programmers and people want to use it for everything, but that leads to it being used for things it has no business being used for. And everyone and their grandmother has their own library/way of doing things/dialect for any given task, which stretches the language beyond its comfortable limits
@hamm8934
@hamm8934 2 года назад
Exactly
@aryandeora6631
@aryandeora6631 2 года назад
But isn't that the BEAUTY of it? It can be bent forwards, backwards and upside down and it still works amazingly! Sure there are caveats but which language doesn't?
@leetaeryeo5269
@leetaeryeo5269 2 года назад
@@aryandeora6631 I mean, it’s convenient, but I don’t think it’s ideal. Different tools/languages are appropriate for different tasks and trying to fit every task to JavaScript just feels like trying to turn a wrench into a hammer-sure, you can probably get to the same place eventually, but you’d have a way easier and better time if you just stopped and grabbed a hammer. Like, I wouldn’t use JS for systems programming, just as I wouldn’t use C for web ui programming and I wouldn’t develop an operating system APL.
@aryandeora6631
@aryandeora6631 2 года назад
@@leetaeryeo5269 fair critique I take your point
@leetaeryeo5269
@leetaeryeo5269 2 года назад
@@aryandeora6631 and I 100% see your standpoint as well. I’m a bit of a hypocrite because I work in C# which has libraries and frameworks for pretty much everything under the sun.
@wlockuz4467
@wlockuz4467 2 года назад
The regex one has actually screwed me over during my live exams, Luckily I was able to write a shitty function to replace what it was doing, but after the exam when I looked at why it was doing it what it was doing I had the same question, WHY?
@ThePrimeagen
@ThePrimeagen 2 года назад
too clever by half of course
@error.418
@error.418 Год назад
Why were you using a global flag in a test function, though? If you're just doing a boolean test, I can't think of a good example where you actually want the global flag. Without the global flag, this isn't an issue. If you are reaching for the global flag, you're probably intending to use a different regex function, not test.
@arsereg
@arsereg 2 года назад
Principal Fullstack Lead developer here, 18 years of experience. I found your top things to hate about javascript really interesting and curious! Thanks for sharing! I think, in my personal opinion, that yes, this things can be really cumbersome, and it can lead to really messy situations where you face an additional layer of complexity. And of course, this things can leave you spending hours debugging your code for a piece of code that can be really difficult to find (Like the 'g' operator in the regex). However, the most I hate from Javascript it's a big portion of the community. Don't get me wrong. I've found many many many developers that create a really diverse and collaboratively community that ends up being helpful, thoughtful, and really really good educators about the perks and quirks of Javascript. However, particularly in Javascript and Python, I've also found the most toxic, irreverent and excruciating members I've faced. A few days ago, I found a video in a spanish-speaking channel focused on Javascript developers. The Video title was: "STOP using for cicles". That catched my attention and I went to watch the video. During the video, the presenter mentioned that instead of using "For" to iterate over a cycle, we should do it using a Array.map function, the reason: Legibility. However, during the video, the presenter also mentioned that the use of Array.map function allows you to "execute your code in a immutable way", which seemed kinda odd, because the very fact that you don't modify something during your code execution doesn't make it immutable. In the comments section, I saw one person mentioning how he disagreed with the video, because of multiple things. I added my support to this comment by also mentioning that the video was referring to Immutability when he wasn't actually doing immutability, as well as an improper use of the Array.map function. Not 5 minutes later, I got attacked by one of the people involved on the conversation saying that "Clearly I was just a junior developer that was scared of the Array.map function", and I just mentioned that even that you could achieve the same result using a for or an Array.map function, the Array.map function has much worse performance in terms of memory usage and time complexity. Long story short, I wrote a piece of code to demonstrate how using Array.map performed 28 times slower and could only manage arrays the 1/11 the size in comparison to use a for cicle, not to mention that the Array.map function semantical purpose is to map an object from one type to another, so using a map instead of a for would make the code "harder to read" because the semantics of the code itself. The next day, the youtube channel published a video that was titled: "Do not optimize your code" and pretty much what the video talked about is how nowadays, computers are so powerful that "small" optimizations are unnecessary, using the code I provided in the previous video. To finish up, I just decided to stop wasting my time with someone who's motto is: "Dont optimize your code". The person kept attacking me for around 3 days, trying to pull me into arguments. And although I've found amazing people that makes a great great great community around Javascript, these kinds of interactions are not rare.
@talhaakram
@talhaakram 2 года назад
There is this strange culture of putting people on pedestals and treating their opinions as facts or the only right way of doing things. If someone disagrees with it, they are treated as lesser skilled developers who simply 'don't get it'.
@arsereg
@arsereg 2 года назад
@@talhaakram Absolutely agree! Also, quite interesting is that as a response for being confronted, he decided to attack me as a person rather than discuss on the technology. This is something we shouldn't do at all when discussing about best methods
@upcomingweeb136
@upcomingweeb136 2 года назад
I actually faced similar experience when I tried explaining to some of my colleagues why typescript is better than JavaScript.
@arsereg
@arsereg 2 года назад
​ @Upcoming Weeb! So sorry to hear that. People are afraid of facing new things or not knowing about something. Honestly and personally, I'm glad when I found something I don't know so that I can study it, and I believe that being so aggressive against such scenarios is definitely a lost opportunity to grow. Sometimes, I think that languages get followers that treat said languages with religious fervour. And are willing to negate reality itself just to attach themselves to their point. This person I was talking about before insisted that the use of Map was better, despite the fact that it performed much, much worse, could handle much fewer data and at the cost of code semantics. His words: "This is the javascript way", reveals this religious fervour I'm talking about. For some reason, he thinks that Javascript existed in a separate realm, where code-optimizations, design patterns, algorithms and data structures don't apply to Javascript because "that's just how javascript works". And he's not willing to accept that he's wrong. That also shows a bit of immaturity in the developer as well. In my personal case, I really love and enjoy working with Java/Kotlin. However, I know that Java/Kotlin have their perks and that sometimes it is not the best fit for all. I'm willing to accept that it is "not the best language", but I do not think such a thing exists. Once again, I'm sorry that you had to pass through that trying to educate your colleagues about typescript. However, you are one clear example of how a community around Javascript can also be a really nice place. Let's keep it that way :D
@talhaakram
@talhaakram 2 года назад
@@arsereg 💯 agreed.
@blt_r
@blt_r 2 года назад
callback to Map.prototype.forEach takes (value, key, map) to be in line with Array.prototype.forEach which passes (value, index, array) to its callback. Because indexes for arrays are same thing as keys for maps
@claytonmarshall8564
@claytonmarshall8564 2 года назад
Was about to comment the same thing. It would have been much worse had they changed the definition of the forEach callback for a single type.
@raffimolero64
@raffimolero64 2 года назад
for consistency the whole thing should just be for v,k if they want to go the route of “you iterate over values but can optionally get the index/key” unless there’s some design philosophy i’m missing, which is likely
@falias4
@falias4 2 года назад
thats actually programming 101... In simple for-loops you work with index and in foreach you work with values. (same thing in other languages too) ... and the second parameter is simply optional
@KnThSelf2ThSelfBTrue
@KnThSelf2ThSelfBTrue 2 года назад
This isn't a JavaScript but a node issue. If you spawn a child process in node, and that node process logs so much that it crashes due to running out of memory, the callback in the parent process gets passed an exit code of - not a number - but the JS value `null`... which JSers will know is dangerously close to 0. So anyway Jest hurts sometimes.... Don't log a bunch of stuff in your unit tests.
@ygeb93
@ygeb93 3 месяца назад
I encountered this problem recently. Jest crashed due to some API call I was making that was spamming warning logs.
@tah3460
@tah3460 2 года назад
Sort() defaulting to sorting lexiographically, despite dealing with numbers.
@weeb3277
@weeb3277 2 года назад
Atwood’s Law: “Any application that can be written in JavaScript, will eventually be written in JavaScript.”
@aymenmt1
@aymenmt1 2 года назад
Math.max(); // -Infinity Math.min(); // Infinity
@ThePrimeagen
@ThePrimeagen 2 года назад
... that cannot be real
@hamzazouari999
@hamzazouari999 2 года назад
@@ThePrimeagen i actually had to test it, he is right, oh hell nauugh
@basudevadhikari22
@basudevadhikari22 2 года назад
My goodness!
@pryflack3646
@pryflack3646 2 года назад
OMG it’s true! 🤣
@astroid-ws4py
@astroid-ws4py 2 года назад
Holy Fk, It is true, Thanks god I am not working with JavaScript.
@keatonhatch6213
@keatonhatch6213 2 года назад
With css at the stage it’s at and faster backend languages, JavaScript should be limited to web carousels and scroll loading.
@ThePrimeagen
@ThePrimeagen 2 года назад
love this idea
@Prod-23
@Prod-23 Год назад
@@ThePrimeagen To be fair, that was the intended use case ... THE ONLY INTENDED USE CASE I might add ... ;)
@inakiarias7465
@inakiarias7465 Год назад
So how would you manage components and application state inside a browser app without JS? Go back to template engines? PHP? Lol
@keatonhatch6213
@keatonhatch6213 Год назад
@@inakiarias7465 you laugh but there’s a reason the largest of web apps still use them.
@inakiarias7465
@inakiarias7465 Год назад
@@keatonhatch6213 Yea, the reason being their code foundation is already built on that...
@scottiedoesno
@scottiedoesno 2 года назад
Silly footgun (and one that does somewhat fall into your type coercion moratorium), but checking whether a variable is undefined vs truthy or falsy as a practice (e.g. foo && ... ) has just caused no end of headaches for my applications in the past. Probably more of a best practices thing and goes back to the community being the problem, but it's still unbelievably aggravating.
@ThePrimeagen
@ThePrimeagen 2 года назад
yeah, i really hate that one.
@bigmistqke
@bigmistqke 2 года назад
I ve written a lil package for it. Rn it's pretty dumb, it just checks if the falsey is not 0 or "", cause those are the situations that i came across that really tripped me up.
@kevinbatdorf
@kevinbatdorf 2 года назад
This is a React concern. As a policy, always check item?.length > 0 and use a ternary
@hakooplayplay3212
@hakooplayplay3212 2 года назад
@@kevinbatdorf yea, ?. I a nice one, but im workin on aws lambda and we have node12 here ... So damn tired of this && checks
@niles_5003
@niles_5003 2 года назад
Could you give an example of a situation that trips people up? And were you using TypeScript at all?
@ethernet764
@ethernet764 8 месяцев назад
1. Regex 2. Buffer/Uint8Array slice 3. Map forEach 4. Bitwise casting to 32 bit signed 5. Community
@oskrm
@oskrm 2 года назад
Clearly, [] is the same as 0. IDK how you'ren't seeing it.
@user-he4ef9br7z
@user-he4ef9br7z 2 года назад
If you're drunk they even look the same.
@kristun216
@kristun216 2 года назад
Loose comparison do be like that in dynamic languages
@ThePrimeagen
@ThePrimeagen 2 года назад
you are perfectly correct, drunkeness is the real reason [] = 0
@u9vata
@u9vata Год назад
When interfacing JS or TS people from my C++ code what I hate most is that they silently send you json with all kinds of shit in it - that is invisible to them because of JS-sloppyness... Like when they randomly send "empty string" instaed of null, undefined as string and such horrible pieces of shit. My code is having tens of special cases for parsing their fucked up shit :D
@srirajnair2594
@srirajnair2594 2 года назад
You said not to use regex , but what is the other alternative to that?
@GiveMeSomeMeshuggah
@GiveMeSomeMeshuggah Год назад
For HTML, use a dedicated parsing library, since HTML is not a regular language. If you’re trying to parse a regular language, there are libraries that allow you to write out a grammar and visit each node of the parse tree. This is a lot less brittle than trying to debug a manual regex parser when the spec changes. And then if you have a use case that’s not a regular grammar and/or you can’t use a library for, (I’m so sorry) reading char-by-char and parsing that way will often be faster and less error prone than a regex.
@ivoevansstorrie3916
@ivoevansstorrie3916 2 года назад
This got me once: function average(averages: number[]) { return averages.reduce((sum, n) => sum + n) / average.length } we divide by average.length, not averages.length, and average.length is for some reason the number of arguments the function takes.
@leilafarahmoussa
@leilafarahmoussa 2 года назад
This is cursed
@anisoseryx
@anisoseryx 2 года назад
Lemme add number 6, this keyword with functions When I started to learn I used a normal anonymous function instead of arrow function within a class, i never suffered like that hour all I needed was the arrow function Number 7 threading: the reason why I switched to another lang whenever I needed threading it's pain =(
@ThePrimeagen
@ThePrimeagen 2 года назад
hah. I didn't want to talk about this. everyone knows about this being a bit confusing. And threading! Its the reason why people _like_ javascript unironically.
@sagarrajak6996
@sagarrajak6996 2 года назад
Use promise brooo
@anisoseryx
@anisoseryx 2 года назад
@@ThePrimeagen I liked at first too I was like woaaa it's cool but it's absolutely painful xd
@parlor3115
@parlor3115 2 года назад
@@anisoseryx No it's not. Promises is a really great API and I see a lot of languages having a similar approach to async programming.
@anisoseryx
@anisoseryx 2 года назад
@@parlor3115 the prove isn't with promises I use them all the time dw, it's for certain cases where threading becomes painful like when I made a discord api wrapper I needed some variables to be shared and it was a real pain to get it done since my variables were constantly changing and needed to be updated across all threads, you can see how complex this problem can be by checking djs code they do that too. Long story short threads are nice but Javascript isn't made for this and I prefer to use another language like csharp to tackle it
@SchneiderRob
@SchneiderRob 2 года назад
I wasn't subscribed. I thought I was a subscriber. But I was not. Now I am. I hope you hit 100k soon dude. Love the videos. Awesome show! Great Job!
@ThePrimeagen
@ThePrimeagen 2 года назад
thanks man! i am so so so close!
@javascripttalks
@javascripttalks 2 года назад
I completely agree that JavaScript was designed for web UI dev and It should be used that way. Most UI developers don't need bit manipulations anyway. Just because you can develop low level networking stuffs with js, doesn't mean you should do. I think developers nowadays are too lazy to learn another language and keep pushing javascript everywhere. Some people think C/C++ is for old people and JS is cool :D
@error.418
@error.418 Год назад
I really hope you're not writing backend with C/C++ when we have much better languages for that domain...
@marcomongalo3328
@marcomongalo3328 2 года назад
Not using regex patterns? What's the alternative you guys use?
@ThePrimeagen
@ThePrimeagen 2 года назад
parser
@marcomongalo3328
@marcomongalo3328 2 года назад
@@ThePrimeagen which type? Although parsers require more code and are slower for short convoluted patterns. Don't you think? On the other hand, parsers are more easily read by humans. Wouldn't regex be "blazingly fast" compared to parsers ? Don't get me wrong, I love me some PEGs
@brentlio5578
@brentlio5578 9 месяцев назад
The best place to use regex is for things that you know for a fact that has a very rigid and predictable pattern. Like repetitive codes and languages. Or just a quick tool for extracting data from large amount of text that you need very often. What regex is really not good at is filtering things that are potentially bad for your purposes.
@Chris-ln3xe
@Chris-ln3xe 2 года назад
1:34 What is the alternative to regex? how do you validate input to an API?
@xoutaku7600
@xoutaku7600 2 года назад
objects in js are nightmarish i don't know why anyone would write production grad code using such an unsafe structure
@kinositajona
@kinositajona 2 года назад
As a library maintainer... my least favorite part of JS is the lack of ECMAScript feature support among the various bundlers and frameworks. The number of issues where "it doesn't work in my React Native app bundled with this new bundling framework that doesn't even say it guarantees support for RN... but for some reason I thought it was your fault so fix it now, slave!" is literally the body of the issue are too damn high... I swear, I tried moving from ES5 to ES6, and people complain about everything. BigInt has been stable and in every browser and NodeJS install under the sun for almost a decade and literally people freaked when I tried to use it and it broke their shit. WHY ARE WE ETERNALLY STUCK AS LIBRARY DEVS ONLY USING ES5!?!?!?!? *pulls out hair* I need a coffee, but it reminds me of JavaScript so I've sworn off the stuff.
@dealloc
@dealloc 2 года назад
Not sure this is bundler issue more than it is configuration/user issue. Most bundlers supports downlevelling ES (i.e. with Babel). Although not unique to JS world, I agree that tools can make end-user think OSS library maintainers are at fault for their broken software is a problem.
@SimonBuchanNz
@SimonBuchanNz 2 года назад
This is actually a case where JS is ahead of other languages, if not perfect: Rust literally just updated their minimum Linux kernel version from 2.6.32 to 3.2 - which came out nearly a decade ago. At least with JavaScript's bundling and polyfilling environment you have a fighting chance of taking a library published using all the latest and greatest features and running it in IE5.5 for Mac. I mean it sucks to do so, but you can...
@quentincaldway
@quentincaldway 2 года назад
The"Bruh" gets me every time! 🤣. Now I need a video on 10 things you Love about rust....Yes....I'm asking for 10 lol. You're hilarious....Your brain oozes with knowledge! Appreciate the value you always give brother! Hope you catch a break with that project you're working on with Netflix lol can't imagine. ~Blessings!
@xBZZZZyt
@xBZZZZyt Год назад
02:58 you can use Uint8Array.prototype.slice.call(buffer,start,end) to always deep copy
@olhoTron
@olhoTron 7 месяцев назад
The forEach callback receiving the value first allows the programmer to save a few keystrokes in the common case of using only the value and not the key... So, yay! for a little longer keyboard lifespan and one fewer unused argument...
@HuntingKingYT
@HuntingKingYT 2 года назад
JavaScript: "is slow" Python:
@ThePrimeagen
@ThePrimeagen 2 года назад
we don't talk about sneks
@sadikkadom9566
@sadikkadom9566 2 года назад
Is it possible to create the C language from Javascript to make Javascript faster?
@SirusStarTV
@SirusStarTV Год назад
Array.prototype methods use (value, index, array) order of arguments (reverse of array[index] -> value), you don't always need index of value when iterating over arrays. Objects aren't iterable so "for of" doesn't work for them, only "for in" for iterating over keys only, Object.entries() does give them iterable functionality and neat syntax of destructuring like [key, value].
@BlitzkriegHD
@BlitzkriegHD Год назад
Gotta say, right off the bat you mentioned the global regex flag and I audibly YELLED after realizing THAT was the reason of some annoying bug in a project I have been working on. Strong start hahaha
@_julian
@_julian 2 года назад
Regex is actually pretty amazing if you take some time to learn it properly
@marcomongalo3328
@marcomongalo3328 2 года назад
Agreed
@window.location
@window.location 2 года назад
You definitely end up using some library, i have been there.
@igoralmeida9136
@igoralmeida9136 2 года назад
just like APL?
@vanjazed7021
@vanjazed7021 2 года назад
There is no excuse for mutable regex object.
@KirkWaiblinger
@KirkWaiblinger Год назад
setTimeout(f, 0) // f is instantly executed setTimeout(f, Infinity) // f is instantly executed
@ThePrimeagen
@ThePrimeagen Год назад
... no way
@KirkWaiblinger
@KirkWaiblinger Год назад
@@ThePrimeagen i see that you just dropped a whole video on this. Nice!
@harleyspeedthrust4013
@harleyspeedthrust4013 2 года назад
I built the account creation page for our site, and I used a regex to validate emails. To be fair it's very loose validation to make sure you have some stuff, followed by an @, with some more stuff containing a dot at the end. And I know there's a bunch of bullshit RFC edge cases and I'm sure it doesn't work on at least a few of them but I don't give a shit because nobody uses email addresses like that anyway, and if they do then they should know they aren't welcome.
@animedreamz2009
@animedreamz2009 2 года назад
I’m surprised that Netflix isn’t using erlang or elixir given how good they are for multi connection services. Imagine having to rewrite the whole backend with rust…but I guess you can use wasm so it could all be rust.
@ThePrimeagen
@ThePrimeagen 2 года назад
i would love to write a backend in rust
@oskrm
@oskrm 2 года назад
@@ThePrimeagen Any reasons why higher-ups don't use Rust?
@MarcosVMSoares
@MarcosVMSoares 2 года назад
Elixir is life bro.
@animedreamz2009
@animedreamz2009 2 года назад
@@MarcosVMSoares I heard that WhatsApp uses erlang and how they were able to scale because of its concurrency and ability to run on low end tech.
@raffimolero64
@raffimolero64 2 года назад
@@oskrm not as tried and teated as other languages, harder to find devs for, has a reputation for being associated with blockchain hopefully time will fix these issues
@redbrickhut
@redbrickhut 2 года назад
I'm working with an API that uses 64bit integers as IDs, I couldn't figure out why all of them were getting rounded for the longest time haha. Gotta love that lost precision.
@ThePrimeagen
@ThePrimeagen 2 года назад
doesn't that just hurt? You have to do the WORST thing in javascript. You either a use big int conversion (then you have to make sure your endians are good) or you keep 2 part keys. just the worst.
@redbrickhut
@redbrickhut 2 года назад
@@ThePrimeagen Yeah, the pill is quite bitter :(
@sct848
@sct848 2 года назад
Man your videos are very entertaining
@t3dotgg
@t3dotgg 2 года назад
Banger video tbh
@Rodriyabala
@Rodriyabala 2 года назад
Prime you've uploaded a video working with the rust framework for web dev "Yew", with assembly around is there something like that but for go?
@ThePrimeagen
@ThePrimeagen 2 года назад
that i don't know
@kevinbatdorf
@kevinbatdorf 2 года назад
immutability wasn’t really a trend until about 5 years ago, so JS still has a bunch of clunky mutable stuff going on. Another classic one is .sort which mutates the source AND returns it.
@ThePrimeagen
@ThePrimeagen 2 года назад
yeah, the returning it really is a bad api. I am happy that its in place sort (the performance would just be so annoying if it wasn't) but returning it gives such a different impression
@bigmistqke
@bigmistqke 2 года назад
O shit i always thought sort didn't mutate
@kevinbatdorf
@kevinbatdorf 2 года назад
@@bigmistqke Lots of people think that. JS should have added a separate method like sortReturn or something to let people choose. You can spread it though like [...items].sort()
@A.D.G
@A.D.G 2 года назад
@@bigmistqke yeah it does, which like prime said, is good, but also bad because the return gives another impression. If you aren’t doing anything too crazy you can spread the array before calling sort for an immutable sort
@dreamsavior1317
@dreamsavior1317 Год назад
I liked it when JS' forEach used value, key. Because in most cases we needed the value instead the key. It would be silly to write .foreach((undefined, value) => ...)when we just needed the value.
@ayyhaha9832
@ayyhaha9832 2 года назад
found out today the modulo operator doesnt work properly on negatives, and the workaround just looks awful
@berduel
@berduel 2 года назад
The module system, especially if you are working with typescript and node. It's a mess, some libraries use common js others ES modules...
@zygote396
@zygote396 2 года назад
not that it necessarily excuses the second issue, but have you heard of the "structuredClone" method?
@ThePrimeagen
@ThePrimeagen 2 года назад
yayaya
@nathanp3366
@nathanp3366 2 года назад
Don't even know javascript because I am a scientist but I still watched the whole ting.
@MuhammadHamza-wj4ev
@MuhammadHamza-wj4ev 2 года назад
Those tricky JavaScript interview questions. Man I hate them. When you switch from a different language to JavaScript, you really say 'Why?'
@davidattlee2734
@davidattlee2734 2 года назад
I want that backstory to the Primeagen. 100k special plz.
@arshadpakkali
@arshadpakkali 2 года назад
1. why is REGEX bad ? i was recently working with MQTT a lot and was using it most of the time 2. i never really used Buffer or UintArray API's at all directly. In which cases are these actually needed? Im just doing TS for 2yrs so eli5 please
@ThePrimeagen
@ThePrimeagen 2 года назад
1. you overmatch regex's all the time. they are also performance nightmares. they also are known for the Regex DOS 2. when you need to work with contiguous memory
@shintaii84
@shintaii84 2 года назад
Prototypes! When you go around Stackoverflow, tutorials, videos. You see it a lot. Just modify the Prototype of the object you are working with. So just change the __proto__ of the array and make it work for you... Not knowing that when you change the prototype of a common type/object, you change it EVERYWHERE not only in your func or lines of code. Maybe not a JS language problem, but more a trap for beginning developers, espcially when not being though wel what the prototype actually is and what it does.
@CheefCoach
@CheefCoach Год назад
Hey, if it have _ in front of the name, it should not be touched.
@mechantl0up
@mechantl0up Год назад
It is not just one or two senior devs that I have had to explain how to remove an event listener in vanilla JS. For some reason, people fail it invariably even after reading the spec. Twice. Or thrice. And people also seem to lack understanding of this. I have been told more than once that webcomponents are nice but it cannot see my context x or assign a listener to button y to use itself because no visibility. Well, just bind. It looks ugly but it is what it is. And I am not even a dev but a consultant who does not do any coding. But still I run a ross devs who know less JS than I do… having to explain a use case for a function closure, or the difference between DOM node types 1 and 3, or why you cannot set :focus state on a non-interactive DOM element without tabindexing it with -1 first, etc. One need not explain pointers to C developers, but JS people are often lacking even the basics.
@gurgen5165
@gurgen5165 Год назад
I don't like using toString or parseInt, it's just to long. Instead I much prefer typing 123 + [] (toString) or "123" - 0 (parseInt)
@adrianburgoscolas520
@adrianburgoscolas520 2 года назад
i've just been bitten by the bitwise operation thing 🤣
@ThePrimeagen
@ThePrimeagen 2 года назад
its so frustrating
@renegade5942
@renegade5942 2 года назад
Typing window.name in your browser search bar to look for documentation of the global variable name will take you to a twitter account
@SimonBuchanNz
@SimonBuchanNz 2 года назад
Always add "mdn" to any JS doc search. Saves so much time.
@PhilipDenys
@PhilipDenys 2 года назад
everytime i watch his vids, my 'imposter syndrom' shows up :D
@lHATETHEINTERNET
@lHATETHEINTERNET 2 года назад
Shout out Hummus
@ThePrimeagen
@ThePrimeagen 2 года назад
hummus?
@flipmedia1597
@flipmedia1597 2 года назад
A superior Mediterranean dip sir
@lHATETHEINTERNET
@lHATETHEINTERNET 2 года назад
@@ThePrimeagen yes hummus it is indeed a very calming relaxing evening snack dip🤌
@snk-js
@snk-js Год назад
the riddles on getting nested variables to be validated before nulish coalesing was inveted is something that triggers me a lot... if(a && a.b && a.b.c && a.b.c.d) { // do that }... Other thing my experience with javascript catches me is when you are dealing comparisons that may return 0, because 0 is evaluated to false, how about that: if(a===b) { // do that } where b is 0, // will evaluate to false, and will not proceed. lol
@inversebrah
@inversebrah 2 года назад
how bout I make a video like "5 Things I Hate Bout ThePrimeagen" how would u like dat Mr.Primeagen
@paytonrules
@paytonrules 2 года назад
A regex for matching emails is a f'ing nightmare. Email validation is shockingly complicated.
@kh_trendy
@kh_trendy Год назад
1:33 I shot myself in my foot with the test flopping values. Super frustrating!
@dleonardo3238
@dleonardo3238 Год назад
1. The language itself 2. The people who use it
@mohamedbelkamel5437
@mohamedbelkamel5437 Год назад
Here is another one, you would expect somearray.every(condition) to return true if the condition is true, which works fine untill the array is empty, then it return false, which is very misleading, Same for somearray,some
@Rudxain
@Rudxain Год назад
3:42 bruh, I hate JS as much as anyone here, but you're ignoring something obvious. forEach is usually used for iterating over values, indices are (almost alaways) useless. Image having to write `arr.forEach((_, v) => v)` everytime you want to ignore the index. This is why `for x of array` iterates only over values. You can do: ``` [...Object.entries(arr)] .forEach(([i, v]) => {}) ``` To get the order you expect. Of course, that code has too much boilerplate, so we'll have to wait for the iterator-helpers proposal to reach Stage 4
@vitiok78
@vitiok78 2 года назад
JavaScript has so many edge cases with weird explanations why something happens that you just literally have to keep track of all of these strange behaviors instead of doing your job. I can't stand it sometimes. You just can't learn JavaScript. It brings the new surprise to me every day. And I have been a frontend developer for 7 years...
@dealloc
@dealloc 2 года назад
Give me an example of a language that does not have quirks that you have to keep track of.
@vitiok78
@vitiok78 2 года назад
@@dealloc JavaScript has all of them.
@spicynoodle7419
@spicynoodle7419 2 года назад
Email regex validation is very easy when you learn that the TLD isn't required for emails and symbols like +, - are valid. Knowing the spec halves the regex expression :^)
@SimonBuchanNz
@SimonBuchanNz 2 года назад
I really wonder what people are even checking for when they are doing email validation. If it's just whether someone didn't understand that it was an email field, just check if it contains an @. Otherwise you're not going to be able to check if it actually exists or whatever!
@spicynoodle7419
@spicynoodle7419 2 года назад
@@SimonBuchanNz definitely
@peacemakerle
@peacemakerle 2 месяца назад
It not just shoots in your food. It blasts your whole leg away.
@stevebitzel
@stevebitzel Год назад
Ok, so what’s the backstory of the name? Is that in another video?
@theowillis6870
@theowillis6870 Год назад
what makes me confused is why does JS have bitwise operators and systems level stuff when it was meant for adding function to websites and not system level stuff like OS's. 💀 also bit wise or takes the or value of each bit like in an integer like this 10 can be represented as 1010 9 in binary us 1001 its 1010 | 1001 which means each byte gets to be or so it should be 1 | 1 , 0 | 0, 1 | 0, 0 | 1 1 0 1 1 1011
@jamesvaci7382
@jamesvaci7382 2 года назад
am i the only one that is now really looking forward to finding out why he goes by ThePrimeagen? even on frontendmasters, while everyone puts their real name on their course, he goes by Primeagen xD
@petarkolev6928
@petarkolev6928 Год назад
If not using Regrets (RegEx) fpr email than how one should validate email?
@user-lb1ib8rz4h
@user-lb1ib8rz4h 2 года назад
i've got a juicy fact that i just learnt about 5 minutes ago: associative arrays are NOT part of javascript. which leads to some hilarious results below. * if you access an array index using a numerical string, it coerces the string into an int. i.e. *a["420"] === a[420]* * _however,_ if it's not a numerical string it treats it as a property of the object. i.e. *a["07"] !== a["7"]* * all indices where you assigned a value (even if that value is `undefined`) WILL return true if you call hasOwnProperty. i.e. *[6,9,4,2,0].hasOwnProperty("4") === true* and even *[6,9,4,2,undefined,0].hasOwnProperty("4") === true* * if you skip an index, it'll fill the indices in between with empty slots (which is somehow different from assigning `undefined` values) so if you call hasOwnProperty on the in-between indices they'll return false (!!). i.e., if you initialise an array *a = [6, 9, 4, 2]; a[5] = 0;* then *a.hasOwnProperty("4") === false* HOWEVER *[6,9,4,2,undefined,0].every((v, i) => v === a[i]) === true* . wtf?? js isn't just too smart by half, it's too smart by half recursively. it's just unbridled genius all the way down.
@user-lb1ib8rz4h
@user-lb1ib8rz4h 2 года назад
honestly, i thought php was the worst language, but after reading the js docs, it's feeling like a strong contender....
@SIMULATAN
@SIMULATAN 2 года назад
Wait, you're still working for Netflix??
@tiberius9283
@tiberius9283 2 года назад
How do you not use regex? Many times it's the best option, can someone elaborate a bit? thanks EDIT: Found the answer in the comment :)
@Sam-cp6so
@Sam-cp6so 2 года назад
Yo prime why you gotta publish this the day I interview to become a JS instructor
@ThePrimeagen
@ThePrimeagen 2 года назад
HAHAH. Use this
@CyrillKR
@CyrillKR Год назад
Number 5 bit me in the ass at the 4th week during development in my first job
@MrSciencedude
@MrSciencedude 2 года назад
Just subbed to get you to 100K!!!! also my first comment ever
@Deadricss5
@Deadricss5 2 года назад
Oh no! I wasn't subscribed! Now it's better!
@Boxing_Gamer
@Boxing_Gamer Год назад
Omg I hate javascript with a vengeance, can't believe it runs 90% of all of a space travelling species software
@soniablanche5672
@soniablanche5672 Год назад
forEach(val,key) makes sense because most people will use forEach(val) only (for Array at least)
@vitiok78
@vitiok78 2 года назад
Shallow copying is pure evil. Period. Give us the fast deep clone alternative! No! We have to suffer!
@ThePrimeagen
@ThePrimeagen 2 года назад
well.. fast and deep aree... well they are sort of opposed to each other.
@vitiok78
@vitiok78 2 года назад
@@ThePrimeagen If it is written in C and is in the standard function then it will be faster than any custom implementation in JavaScript
@SimonBuchanNz
@SimonBuchanNz 2 года назад
@@vitiok78 firstly, that's actually the sort of thing that runtimes are good at making as fast as C, secondly C is slow as deep copies too. Because a deep copy is by definition a lot of work. You could ask for immutable data structures though...
@KnThSelf2ThSelfBTrue
@KnThSelf2ThSelfBTrue 2 года назад
Door number three: copy-on-write???
@oussamabouchebak6877
@oussamabouchebak6877 2 года назад
So you suggested we avoid using regex, so what's an alternative to testing a pattern on a string?
@fearmear
@fearmear 2 года назад
Use String.prototype.match instead
@hsrkfzycfod8
@hsrkfzycfod8 2 года назад
ThePrimeagen's gonna carry us to the top, bruh. 2023 is gonna be the year of Rust and NeoVim.
@ThePrimeagen
@ThePrimeagen 2 года назад
agreed
@ytpeerz
@ytpeerz Год назад
Don't you just love it
@karelhrkal8753
@karelhrkal8753 2 года назад
Damn, the stateful regex is a thing straight from a nightmare. If it weren't for TypeScript and it's honestly pretty great type system JS would be nearly unusable.
@ThePrimeagen
@ThePrimeagen 2 года назад
yeah, typescript sort of makes it ok.
@dmassolari
@dmassolari 2 года назад
One thing I hate is that you don't have an easy way to compare objects, like { a: 1, b: 2 } === { b: 2, a: 1 } // false :(
@vjau75
@vjau75 11 месяцев назад
JSON.stringify
@gorkemgenc344
@gorkemgenc344 Месяц назад
how about 5.0 - 2.5 = 2.5000000000000001
@ICoulntThinkofAUserNam547
@ICoulntThinkofAUserNam547 2 года назад
what to use in place of regex, exactly? It's ubiquitous
@ThePrimeagen
@ThePrimeagen 2 года назад
Write a parser. They're extremely simple, it's a great exercise to do, and they're easily maintainable for almost all situations. The situations in which they don't, there's almost always a library instead of cutting and pasting regex from the internet
@__samuel-cavalcanti__
@__samuel-cavalcanti__ 2 года назад
It's not fair. Javascript obviously isn't perfect, but every try to replace Javascript fails. to be fair, you should have a 5 reasons to use Javascript BTW maybe Dart on back end can be blazing fast ( do you believe in this comment or you will make your own benchmark and post on youtube ? )
@MrPoselsky
@MrPoselsky 2 года назад
How would you compare it to Elm?
@LuccDev
@LuccDev 2 года назад
Well, to this I'd simply had the fact that the overall environment is super tedious to master, with all these config files bundling together, which are annoying to master or even understand, the fact that it doesn't really do multi processing "out of the box" and has a super shitty multiprocessing API even now, the callbacks vs promises mess... And yeah mostly the fact that it's used for everything despite being super slow. Also, the fact that it's a language that has a ton of different versions depending on where and how you use it (node VS chrome VS firefox VS mobile etc.), but well this would be a drawback of other languages as well I guess. Also, the fact that the packages are all centralized in one microsoft-owned repo, the fact that a lot of simple and classic libraries have bugs or archaic parts that are like 5 years old sometimes..
@kishDoesThings
@kishDoesThings 2 года назад
prime is the doc of programmers
@ronakmehta8106
@ronakmehta8106 2 года назад
Yo prime the foreach gives key value only, if you do Object.entries(OBJECTNAME).foreach((key,value) => console.log(key,value)) am I missing something here ?? Oh it is for map ok sorry I missed that sorry.
@ronakmehta8106
@ronakmehta8106 2 года назад
Object.entries({a:1,b:2}).forEach((key , value ) => { console.log("key "+ key + " value" + value) ; })
@tinnick
@tinnick 2 года назад
The difference between an iterator returned by Object.entries() and Map.forEach maybe?
@ThePrimeagen
@ThePrimeagen 2 года назад
it was specifically on map. Entries is a god awful api as it creates HUGE garbage. it literally creates an array just for you to iterate it...
@ronakmehta8106
@ronakmehta8106 2 года назад
@@ThePrimeagen yep I have to use to it for traverse dom mostly.
@ronakmehta8106
@ronakmehta8106 2 года назад
@@tinnick we get a array of array of two elments and I am talking about this [ ["key1",value1],["key2",value2]] and you destructure it later for use,so you are technically getting the value of the Parent array which is the child array. So kinda makes sense of value comming first in the case of map.
@Khusyasy
@Khusyasy 2 года назад
yeah i really hate the regex thing, once i tried to use it to parse data from a string, and it didn't work because i need to use matchAll instead of just match with the g flag
@skwtf
@skwtf 2 года назад
Those and more are the reasons I moved to writing Go a few years ago.
@CrazyFanaticMan
@CrazyFanaticMan 2 года назад
Finally someone admits Python supremacy
@wisdomelue
@wisdomelue Год назад
can you ship out a complete full stack project with just python?
@yxngboypolo
@yxngboypolo Год назад
In what sense, performance 💀
@CrazyFanaticMan
@CrazyFanaticMan Год назад
@Emmanuel JS is slow too. Rust, C/C++ and Java are faster than both Python and JS But Python is far superior than JS JS should stick to building UIs, not sure why anyone would wanna do ML in JS
@yxngboypolo
@yxngboypolo Год назад
@@CrazyFanaticMan there has been a misunderstanding, I agree with you.🤝
@CrazyFanaticMan
@CrazyFanaticMan Год назад
@@yxngboypolo I love you ❤️
@DanieleScasciafratte
@DanieleScasciafratte Год назад
I am the one about at 0:07 XD
@T1Oracle
@T1Oracle Год назад
I hate JS, but it's the only way to do web apps and every app has to be a web app since 2010. I'll never escape it.
@akshitsingh6429
@akshitsingh6429 2 года назад
wheres elixir
@absencelul
@absencelul 2 года назад
you better take this video back javascript is love
Далее
Is JSON Blazingly Fast or...?
9:57
Просмотров 193 тыс.
100 Identical Twins Fight For $250,000
35:40
Просмотров 32 млн
CORTE DE CABELO RADICAL
00:59
Просмотров 1,9 млн
JavaScript Is Weird (EXTREME EDITION)
21:29
Просмотров 687 тыс.
How Slow Is JavaScript? | Prime Reacts
15:34
Просмотров 179 тыс.
My Best Decision Professionally
5:40
Просмотров 150 тыс.
Why I Use C | Prime Reacts
13:00
Просмотров 159 тыс.
The Weird History of JavaScript
12:09
Просмотров 1,2 млн
JSON, I hardly know 'er
2:52
Просмотров 187 тыс.
The Weird Rise Of Anti-Startups
12:57
Просмотров 281 тыс.