The Weird Parts of JavaScript

Поделиться
HTML-код
  • Опубликовано: 29 ноя 2024

Комментарии • 110

  • @ennakrbouchaib9139
    @ennakrbouchaib9139 5 лет назад +14

    Any function well be work with a number, just make two points.
    like this : 10..toFixed(x)
    because the first point is not to reference, for the dozens, like 10.2 or 10.1

  • @Nicoarielpkr
    @Nicoarielpkr 5 лет назад +65

    I know nothing about him, but i'm just being nice, had me spitting my coffe :P

  • @AAA-bo1uo
    @AAA-bo1uo 5 лет назад +1

    Lol.. supervisor chose JS (node) for our project because it's event driven and non I/O blocking, then proceeded to tell us to explicitly use it in a sync manner whilst using external libraries... imagine trying to use an environment and eco system based on async in a synchronized manner.. it's crazy.

  • @martinkrisell7953
    @martinkrisell7953 5 лет назад +3

    Great video! However the problem with a newline after the return keyword is unaffected by the recommendation to "always use semicolons". Even if you write your semicolons, undefined will be returned. The only way to avoid it is to learn to not put return on its own line, and that has nothing to do with semicolons.

    • @madmanX1314
      @madmanX1314 5 лет назад +1

      Martin Krisell Yes. That is being confused so often

  • @Luxcium
    @Luxcium 5 лет назад +14

    Thank for your amazing and passionate work this kind of topic is truly interesting... I am wondering if you plan on doing something about back end like NodeJS one day soon

    • @ColtSteeleCode
      @ColtSteeleCode  5 лет назад +2

      Working on some Node content for a new course right now. I'm happy to make RUclips videos on it, but it's kind of a large topic so I need suggestions about what in particular to cover!

    • @Luxcium
      @Luxcium 5 лет назад +2

      Colt Steele please 🙏 please 🥺 don’t do like in the 75 Udemy Intro course I have purchased... if you do something NODEJS on your RUclips channel it’s *not* required to be web server stuff again (NodeJs can do way more) please teach us what we can’t get from those tutorials... explain us the real stuff: (streams, piping, buffers, sockets and +CHILD PROCESSES+) all that great stuff we all need a library to do and that we can’t quite understand after all beginners tutorials ... NodeJs is amazing and the tutorials don’t explain how it works inside (except for the existence of the event loop) ...

  • @TyDurr1
    @TyDurr1 5 лет назад +2

    I can at least speak to NaN !== NaN. Essentially, it is _intended_ to make your code fail fast and hard, so that you know as soon as possible during execution that some calculation you did gave you a number that wasn’t a number. On top of that, all operations where an operand is NaN will result in NaN as well, and all comparisons against NaN return false, again in an attempt to protect you from utilizing that value somewhere where it could break something.

  • @BrokoIis
    @BrokoIis 5 лет назад +1

    I thought I knew most of the weird things of JS, but this video just showed that there's more!

  • @micoberss5579
    @micoberss5579 5 лет назад +30

    Javascript is all weird

  • @yuhceeofficial
    @yuhceeofficial 5 лет назад +1

    I am glad you have posted a video. I have really missed you.

  • @SentimentalMo
    @SentimentalMo 5 лет назад

    JavaScript designers: “hmmm, how can we break the rule of least astonishment……as much as possible? Let start by making true == false‼️”

  • @intisark587
    @intisark587 5 лет назад +2

    Hi,colt can you do a vidio on css grid,would be really helpful

  • @ismaelgoldsteck5974
    @ismaelgoldsteck5974 5 лет назад

    1.toFixed(1) is not unexcpected since js wants a floating point number. Just write 1..toFixed(1)

  • @danielzaiser
    @danielzaiser 5 лет назад

    12:20 you said it represents infinity if it has all zeroes, but it's actually ones, and it says so right there on screen as well

  • @jadedansk5631
    @jadedansk5631 5 лет назад

    3:30, I believe this is cause putting a ‘.’ by a int literal makes js think you’re trying to make a float

  • @sobanya_228
    @sobanya_228 5 лет назад +1

    It's much easier to learn rules of omitting semicolons and make prettier format it in a way you need automagicaly (either with or without, depending on the standard you use)

    • @khattami240193
      @khattami240193 3 года назад

      i omit semicolon in all my codebase, for the sake of readability

  • @AJQuickShow
    @AJQuickShow 4 года назад

    Hello bro i recently brought your web development boot camp course it was awesome 👍
    Thx for your effort

  • @harshpatel7704
    @harshpatel7704 5 лет назад

    I think it might help others. This same method describes the areay problem in video too!

  • @puppy0cam
    @puppy0cam 5 лет назад +2

    The only time I use == is to treat null and undefined as the same thing.

    • @omnijack
      @omnijack 5 лет назад

      There are situations where null and undefined behave very differently, so learn to use === and always check for exact values.

    • @puppy0cam
      @puppy0cam 5 лет назад

      @@omnijack in my use cases I don't need to use the value, I just need to know that it doesn't care about the value.

    • @Luxcium
      @Luxcium 5 лет назад

      You are using != undefined to check both (instead of !==) but == undefined is not the same thing (I am usually using != undefined to test it’s not undefined or not null but I don’t use == undefined)

  • @harshpatel7704
    @harshpatel7704 5 лет назад

    Javascript just evaluates an object with value as true. Like an areay with one element. While empty string or array as false as it does not have any method. Thats why we check that string has value by just sending string as a argument to if statement.

  • @doublex85
    @doublex85 5 лет назад +4

    35..toFixed(1)

  • @MaxPicAxe
    @MaxPicAxe 5 лет назад +1

    I am truly against this automatic semi-colon insertion. Ok, some may consider it convenient. But it prevents many ways of formatting your code. I always like to put my braces on new lines but there are many situations where this can't be done in JS like you showed with the return statement.

    • @circuit10
      @circuit10 5 лет назад

      I don't agree- I always forget them. Maybe it should be optional.

    • @CathrineMacNiel
      @CathrineMacNiel 5 лет назад

      That's the reason why every language ever has a coding guideline that you (in JavaScript) enforce with eslint.

  • @solesolver5740
    @solesolver5740 5 лет назад

    Which browser theme do you use?

  • @Luxcium
    @Luxcium 5 лет назад +3

    Ok so 123..toFixed(2) is ok ...

  • @yuhceeofficial
    @yuhceeofficial 5 лет назад +2

    Do a video explaining how javascript runs its program, closures and the event loop. That is, what actually happens behind the scenes when you run your code. Thanks

  • @rachada2532
    @rachada2532 5 лет назад +4

    Redux please ❤️

  • @keemeshrampersad8859
    @keemeshrampersad8859 5 лет назад

    Love your work Colt...

  • @surjagain
    @surjagain 5 лет назад +1

    Got a headache now :) Thanks for the fun video :)

  • @theholygang1
    @theholygang1 3 года назад

    typeof NaN
    returns 'number'

  • @williamdrum9899
    @williamdrum9899 2 года назад

    I didn't even know javascript had a double equals lol. I've never used it but I have seen what the code looks like

  • @Reellron
    @Reellron 5 лет назад

    The following statements are oddly false as well:
    0.1 + 0.2 == 0.3
    10.495 + 4.8 == 15.295
    10.495 + 34.8 == 45.295
    The following statement is true, which screwed my application up today, until I found it out and rounded it off.
    10.495 + 34.8 == 45.294999999999995
    The numbers on the left hand side were compared to a value in MS SQL DB table, which was 45.295..

    • @williamdrum9899
      @williamdrum9899 2 года назад

      That's not a Javascript issue, it's an inherent flaw in IEEE 754 floating point representations.

    • @Reellron
      @Reellron 2 года назад

      ​@@williamdrum9899, whether it's a javascript issue or not is more of a philosifical argument. It's an issue that exists in JavaScript, that it's inherited is not as important.

    • @williamdrum9899
      @williamdrum9899 2 года назад

      @@Reellron By that I meant that almost every programming language is like this, floating point and binary just don't work together well. You're trying to represent something that can potentially be infinitely long so you can only get a ballpark estimate. What I don't get, however, is why the computer can't understand that the answer to an addition problem can't have more significant digits than the operands and round off based on that

  • @GleamGoldenrock
    @GleamGoldenrock 5 лет назад

    Great video!

  • @aliemadzadeh9293
    @aliemadzadeh9293 5 лет назад

    thanks:) it was fun. I did not know

  • @DanielSouza-nq1hw
    @DanielSouza-nq1hw 5 лет назад

    Shit that hurts my brain

  • @dima6488
    @dima6488 5 лет назад +1

    Give me Redux or give me death!

  • @zotac1018
    @zotac1018 5 лет назад

    What ide are you using here?

  • @prateeksingh6757
    @prateeksingh6757 5 лет назад

    Why no one have good JavaScript ES6 course on udemy.

    • @ColtSteeleCode
      @ColtSteeleCode  5 лет назад +16

      I just finished recording my new es2015/es6 course last night! Now I have to do all the editing, but the course is completely recorded.

    • @prateeksingh6757
      @prateeksingh6757 5 лет назад

      @@ColtSteeleCode I will join the course on udemy.

    • @sabikksabikk6156
      @sabikksabikk6156 5 лет назад

      Waiting for course, your explains is greate

    • @Luxcium
      @Luxcium 5 лет назад

      Colt Steele will you do ES7, ES8, ES9, ES10 LoL ... also will I get a bigger discount if I already know JavaScript but I like the way you teach and want to follow along or can you hack me a bootlegger version LoL 😂

  • @yuhceeofficial
    @yuhceeofficial 5 лет назад +3

    You didn't update us on how your chicks pets are doing?

    • @ColtSteeleCode
      @ColtSteeleCode  5 лет назад +2

      I will in the next video, I promise! I was going to include some video of them today, but the room they are in right now is very messy and I didn't want people to see that :) They are growing so fast, it's amazing to see.

    • @yuhceeofficial
      @yuhceeofficial 5 лет назад

      @@ColtSteeleCode Aww... That's so cute. But it's kinda funny that they are enjoying this care now to only to end up in your belly someday...😂

    • @puesnovay
      @puesnovay 5 лет назад +4

      @@yuhceeofficial what!?

    • @Luxcium
      @Luxcium 5 лет назад +1

      Egbo Uchenna Matthew 😮 he will not only eat the eggs 🍳? I don’t think he would be able to eat them he will be like their father (but if it’s a rooster 🐓 he will have to eat it instead of it’s eggs... eating exclusively roosters eggs is dangerous and caused many to die of starvation)

  • @Hyp3rSp8c3
    @Hyp3rSp8c3 5 лет назад

    Ay.. yay, yay! This is the source of my headache. :-)

  • @ZighyBlue
    @ZighyBlue 5 лет назад

    JavaScript is like the honey badger... Soo nasty! ;)

  • @kamran6998
    @kamran6998 5 лет назад

    hi colt.. is there anyway that we could contact you? like by email or anything else? I need some advice from a professional programmer???

  • @lucasfelipe-ze5sy
    @lucasfelipe-ze5sy 4 года назад

    javascript == weird // true
    javascript == javascript // false

  • @Cognitoman
    @Cognitoman 5 лет назад +5

    Javascript isn’t weird....php is weird lol I promise

  • @ahmadganteng7435
    @ahmadganteng7435 5 лет назад +2

    Hi.. I am a javaneese..
    FYI, this complexity is just way too little compared to the real java language (a.k.a boso Jowo)..
    Lol

  • @cintron3d
    @cintron3d 5 лет назад

    Great video, but I disagree on the semicolons bit. I prefer to just not use semicolons and write functions like this `const myFunc = () => { ... }`

  • @dtellei
    @dtellei 5 лет назад

    i-triple-e? :)

  • @jsonkody
    @jsonkody 5 лет назад

    W8 what??? That semicolons section: "and thats why you should ...". No! If you know what you doing you should ommit these stupid semicolons.

    • @jsonkody
      @jsonkody 5 лет назад

      Also that return situation where it matters cannot be save d by typing semicolon. You just need to start onject on same line so whats the point in typing semicolons everywhere?

  • @TheMessixaviniesta
    @TheMessixaviniesta 5 лет назад +2

    Javascript is a mess

  • @christianthompson1839
    @christianthompson1839 5 лет назад +4

    Solution: don't use JavaScript

  • @SuperemeRed
    @SuperemeRed 5 лет назад +1

    I will NOT put semicolons in my private code, it's ugly and tedious to write. As far as I know you only need to add a semicolon on a new line when it starts with a round or square bracket.
    ;(...) // like this.

    • @nicholasmaniccia1005
      @nicholasmaniccia1005 5 лет назад +5

      Not ugly use a linter, and if that's tedious idk man that says more about you

    • @SuperemeRed
      @SuperemeRed 5 лет назад

      @@nicholasmaniccia1005 Haha I'm fine with being lazy in my private code ^^
      BTW how is a linter going to help me hide those ugly semicolons? I don't like them visually, they clutter up readability.

    • @salembeats
      @salembeats 5 лет назад

      @@SuperemeRed A semicolon denotes the end of a statement, just like a period denotes the end of a sentence.
      Are you gong to stop typing periods at the ends of your sentences as well?

    • @SuperemeRed
      @SuperemeRed 5 лет назад

      @@salembeats I know this, also as mentioned in the video, JS auto adds semicolons for you, this is a topic that has been discussed many times before in videos, articles and forums, and the conclusion is that there really is not a problem with omitting the semicolon (statement ender) as it will be auto inserted any way, the only scenario that will break is when you begin a new line with ( or [ and all you have to do is begin the line with ; in-front like this ;( and all is well. But of course, follow the code convention when you are collaborating with others. The point is that it's like, why manually add a period when the editor will automatically add it for you. And while I get you, the period and semicolon isn't a perfect 1 to 1 comparison in the way the statement or sentence is terminated due to new line and brackets and so on.

    • @SuperemeRed
      @SuperemeRed 5 лет назад

      @@nicholasmaniccia1005 Here is a great video explaining the reasoning for omitting semicolons: ruclips.net/video/Qlr-FGbhKaI/видео.html

  • @avibank
    @avibank 5 лет назад +2

    Javascript is a vulgar language.

    • @Luxcium
      @Luxcium 5 лет назад +2

      avi bank I am in love with JavaScript and his curse 🦹🏼‍♂️ If you prefer well behaved people then you should probably date JS little sister TypeScript she is an angel 😇

  • @Steve-Richter
    @Steve-Richter 5 лет назад

    I have never had to use ===.

    • @Luxcium
      @Luxcium 5 лет назад

      Zahra Q my friend which was working on construction 🏗 sites never needed a harness and now he’s dead 💀 LoL 😂

  • @mortyjr2334
    @mortyjr2334 5 лет назад

    Everything is weird in JavaScript, in my opinion it's one of the worst languages out there.