Another 5 Must Know JavaScript Features That Almost Nobody Knows

SdĂ­let
VloĆŸit
  • čas pƙidĂĄn 4. 07. 2024
  • 🚹 IMPORTANT:
    JavaScript Simplified Course: javascriptsimplified.com
    JavaScript is a vast language with tons of features and it is impossible to know them all. In this video I will be covering yet another 5 features in JavaScript that nobody knows but are incredibly useful.
    📚 Materials/References:
    First JS Must Know Features Video: ‱ 5 Must Know JavaScript...
    Second JS Must Know Features Video: ‱ 5 MORE Must Know JavaS...
    JavaScript Maps Article: blog.webdevsimplified.com/202...
    JavaScript Sets Article: blog.webdevsimplified.com/202...
    Reference Vs Value Video: ‱ Reference Vs Value In ...
    Reference Vs Value Article: blog.webdevsimplified.com/202...
    🌎 Find Me Here:
    My Blog: blog.webdevsimplified.com
    My Courses: courses.webdevsimplified.com
    Patreon: / webdevsimplified
    Twitter: / devsimplified
    Discord: / discord
    GitHub: github.com/WebDevSimplified
    CodePen: codepen.io/WebDevSimplified
    ⏱ Timestamps:
    00:00 - Introduction
    00:57 - Loop Labels
    06:07 - Object.freeze
    09:18 - Map
    12:32 - Set
    13:56 - Binary Math
    17:39 - Debugging Tips
    #JSTips #WDS #Top5JS

Komentáƙe • 500

  • @prometheas
    @prometheas Pƙed 2 lety +117

    Been working with JavaScript on and off since 1998, and I still find tons of values in your videos. Kudos, Kyle, on these excellent tutorials-you’re a real community asset

    • @richardwelsh7901
      @richardwelsh7901 Pƙed 2 lety +4

      I feel like the ECMA spec has evolved so much since the initial releases that we should be calling it JS++

    • @iapplethis
      @iapplethis Pƙed 2 lety +1

      lol

  • @SilviuBurcea1
    @SilviuBurcea1 Pƙed 3 lety +16

    So in case anyone wondered how decimal numbers can be represented in memory. If we push a 1 to the left, we double its value. If we push it to the right, it's going to be halved. So let's do it, starting with 1:
    decimal -> binary
    1 -> 1
    .1 -> 0.5
    .01 -> 0.25
    .001 -> 0.125
    Need 0.75 in decimal? That's 0.5 + 0.25 so it would be .11. Now let's look at the famous 0.1 + 0.2 = 0.30000004.
    0.1 (dec) is smaller than 0.125 (1/8) so we need the next 2^-x power, 1/16, that's 0.0625 (.0001 binary). We're left with 0.0375, which is a bit larger than 1/32 (0.03125 dec, .00001 binary). 1/16 + 1/32 is therefore 0.09375 in decimal (.00011 binary). We would need 0.00625 more to 0.1, we're getting closer to 0.1, but in this case, since 0.1 can't be a sum of 2^-x powers, you will reach the maximum number of bits threshold so your value gets truncated. Imagine if he had only 4 bits, the best binary representation for 0.1 would have been 0.0001, which is only 0.0625!
    0.2 (dec) is larget than 0.125, so we have .001 for starters, we need 0.075 more, which is between 1/16 and 1/8, so we have 1/8 + 1/16 so far (0.125 + 0.0625 = 0.1875, .0011 in decimal). We would need 0.0125 next, which, again, is not a sum for 2^-x powers and 0.2 representation is again truncated. You get close, but never 0.2 exactly.
    This is why you're not getting 0.3 for adding 0.1 and 0.2, which also doesn't have an exact binary representation. 0.1 + 0.2 in binary is like adding 2 truncated numbers, the way you would do 975 + 210 in decimal, about 1000 + about 200, that should be about 1200.

  • @lukahadziegric5982
    @lukahadziegric5982 Pƙed 3 lety +113

    I mean... labels are essentially GOTO statements. Sure, there are times when you want to use them, but they are usually a bad thing because it makes code less readable in more complex examples. For this first example, you can just use a "break" statement to break out of that inner loop.

    • @nickscott9832
      @nickscott9832 Pƙed 2 lety +32

      Or just check the condition in the outer loop

    • @lord_kh4n
      @lord_kh4n Pƙed 2 lety +1

      True, we need a concise example of when to use the labels I think

    • @TheGreatMcN
      @TheGreatMcN Pƙed 2 lety +6

      If a labeled break is like a goto, then how is unlabeled break not like a goto?

    • @TheNewGreenIsBlue
      @TheNewGreenIsBlue Pƙed 2 lety +3

      @@TheGreatMcN GOTO statements are icky. I mean... it's what the compiler is ACTUALLY doing really low level... but yeah, I'd consider rearchitecting the code before using labelled gotos. Like, consider using functions and return statements.

    • @TheGreatMcN
      @TheGreatMcN Pƙed 2 lety

      @@TheNewGreenIsBlue Sure, I agree with that. That doesn't answer my question though.

  • @mhombach3035
    @mhombach3035 Pƙed 2 lety +25

    I mean, for the "Binary Math" solution I would highly recommend using Math.round and just round the comparing values to 2 decimals or so. Or directly round the values after each math-operation to x decimals so you can then later compare them to 0.35 directly.

    • @huge_letters
      @huge_letters Pƙed rokem +2

      I would actually suggest using a library specifically made for dealing with decimals(like decimaljs or bigjs) - especially true if you're working with some financial data and rounding it would be rather risky.

    • @mhombach3035
      @mhombach3035 Pƙed rokem

      ​@@huge_letters As always it "depends on the usecase". For financial data that could be worth a shot, but then again you are depending your financial data on some "dude" who has issues open since 2018 which haven't been closed. If you are too lazy to repeat "Math.round()" in your code, you should consider writing util functions yourself, so you drastically reduce the likelyhood of bugs. For example write a "sum([decimalsArray])" function that returns with a precision of 2 by default and can be adjusted by parameters. I also read somewhere that a new datatype is coming that will fix this, but i can't find any info on that so maybe I have faulty memory here...

  • @GetawayJamie
    @GetawayJamie Pƙed 3 lety +14

    This video is like window shopping, you find things you never thought you needed!

  • @KyleLanmon
    @KyleLanmon Pƙed 3 lety +247

    IMO if you need labels, that is a code-smell

    • @RoiTrigerman
      @RoiTrigerman Pƙed 3 lety +18

      it's like goto.. it's EviL!!

    • @foxoninetails_
      @foxoninetails_ Pƙed 3 lety +23

      Worth noting for the sake of other readers that code smell *does not* mean bad code. It's just a potential red flag, something to watch out for and be wary that it might be bad code. Labels are extremely useful when you need them, but overuse is definitely something to be careful of.

    • @keenkidash7616
      @keenkidash7616 Pƙed 3 lety +2

      @@foxoninetails_ Actually is a smell of bad code. If you have to watch out for that chunk, it is bad, indeed, so you are obligated to put more effort into it in order to maintain the code base.
      Btw, the nested loop example is easy solved by function extraction (and you are allowed to *return* whenever you want to continue to the next iteration)

    • @foxoninetails_
      @foxoninetails_ Pƙed 3 lety +19

      @@keenkidash7616 The term "code smell" does not and has never referred to bad code, except when used by people who have no idea what they're talking about. It was coined specifically to refer to code that is often, but not necessarily, indicative of bad design. Labels, like any other code smell, are not inherently bad, but rather should be used sparingly and thoughtfully. They are a valuable tool, but not one which should be used without good reason.
      And no, "the nested loop example" (which one? I'll assume the most common, breaking out of multiple loops) can't be trivially solved by function extraction. Labels allow you to break or continue from specific levels of a nested loop at any point inside them; to do so via function extraction, in more extreme cases, requires the inner functions to return some form of signal value which tells the previous function that it should also do the same, which becomes an unbelievable mess to manage.

    • @adicide9070
      @adicide9070 Pƙed 3 lety

      yeah i can already see someone senior to me being cool with 3, 4, 5 levels of for loop nesting ;)

  • @Bazkur98
    @Bazkur98 Pƙed 3 lety +15

    I'm amazed that after so long of working in JS that I can still learn something new. This time around, the console Timer and debugger option :) Thanks for sharing!

  • @KurtSchwind
    @KurtSchwind Pƙed 3 lety +18

    Tip for those trying to compare equality on decimal arithmetic: Use subtraction and an epsilon. IE: let epsilon = 0.00001 (or whatever precision you like) and re-write your equality to if Math.abs(x-Comparison_Value) < epsilon { }. In your example it would be if (Math.abs(x-0.35) < epsilon) { // do stuff }

    • @adtc
      @adtc Pƙed 3 lety

      Couldn't you just floor it and check for zero? Just curious...

    • @KurtSchwind
      @KurtSchwind Pƙed 3 lety +1

      @@adtc Flooring will truncate the decimal part completely. So if you were to compare 0.9 with 0.3 with a floor it'd be equal. Unless I'm not understanding where you are using the floor function. Math.floor(0.9-0.2) === 0 -> true. But I think most would want that to be falsey

    • @adtc
      @adtc Pƙed 3 lety +1

      @@KurtSchwind oh right, I don't know what I was thinking đŸ€Ș thanks

    • @arjix8738
      @arjix8738 Pƙed 3 lety

      or just calculate using whole numbers (integers) and then convert them to decimals
      eg divide it by 10 => 3/10 == 0.3

    • @KurtSchwind
      @KurtSchwind Pƙed 3 lety +1

      @@arjix8738 Int math is prefered, but not always an option, it will depend on the size of the numbers you are using. If you want precision to 6 decimal places, you'll have to multiply by a million and then divide at the end, which may or may not be ok. But in general, I do agree that if you know that your numbers are safely not going to overflow, that converting to int and back is the best. For money transactions, I leave everything in pennies (or cents or whatever) and then convert on the presentation layer.

  • @magicfibre
    @magicfibre Pƙed 3 lety +11

    9:58 No, it's not hard at all. You can use Object.keys, Object.values and Object.entries to effortlessly loop through anything you want. Being able to use an object as a key is super cool though! Would be even cooler if object comparison wasn't such a pain in JS 😅

    • @huge_letters
      @huge_letters Pƙed rokem +2

      Objects should be used for storing data where your keys are pretty much static and known and well-structured - like you have a person entity which has a name, age, location etc.
      Map was made specifically for situations where you want a relationship between arbitrary number of keys and values. It's optimized such cases too.
      Object.keys, values, entries create a new object in memory on top of the one you already have.

  • @CaddyBlue
    @CaddyBlue Pƙed 3 lety +4

    On Binary Math. I would advise multiplying, rounding and diving to significant decimals to ensure that the input condition is treated to match our condition.
    e.g. Math.round(num * 100) / 100 for 2 decimal.
    Same with strings :
    Always do a if( {input}.toLowerCase().trim() == {condition}.toLowerCase().trim() ) {}
    I would say these 2 methods are life savers when you want String and Number comparison.

    • @montebont
      @montebont Pƙed rokem

      Here is a generic rounding function. This example is a static function in my class MathLib. Sorry about the formatting...
      static round(number, precision) {
      const power = 10 ** precision;
      let result = Math.round((number * power).toPrecision(15)) / power;
      return result;
      }

  • @jameswalker9490
    @jameswalker9490 Pƙed 3 lety +3

    This is really well done! I like the way you structure your video. The code, output, and video layout makes it easy to follow. Keep it up!

  • @revidee
    @revidee Pƙed 3 lety +14

    17:12 you can use Number.EPSILON in combination with Math.abs() to include these tolerances. Eg.: Math.abs(x - 0.35)

    • @CottidaeSEA
      @CottidaeSEA Pƙed 2 lety

      That's a really bad idea as you can't assert that Number.EPSILON has a good enough tolerance.
      Example:
      Math.abs((0.1 + 0.2) - 0.3) < Number.EPSILON is true.
      Math.abs((1000000.1 + 0.2) - 1000000.3) < Number.EPSILON is false.
      Clearly the difference should be the same, yet the tolerance is insufficient. Your best bet when working with things like these would be to use a custom tolerance. The approach is sound, but relying on Number.EPSILON is not.
      It would also be possible to use Math.abs, multiply by 10^n and then Math.round to get an integer value, after which you can make an assertion. I haven't tested it extensively though, so I can't guarantee it works in all cases, but it's a possibility for some cases I can think of.

  • @gosnooky
    @gosnooky Pƙed 3 lety +11

    It's always a bad idea to assert equally with floating point values. They're mostly useful in games, math, geo spacial and other applications where accuracy to 1/10000ths are not important. Always use whole integers when dealing with money values where 1 is the smallest unit of a given currency, and use number formatting when displaying to a UI.

    • @benscherer7256
      @benscherer7256 Pƙed rokem +1

      though in js there is no integer type so you always need to be careful when working with primitive number types because it is a float.

    • @huge_letters
      @huge_letters Pƙed rokem

      @@benscherer7256 you are correct but I'm pretty sure you don't have to worry about that if your values are integers - you won't get any weird rounding errors.

  • @AeroPR
    @AeroPR Pƙed 2 lety +5

    The For labels seem like a great way of documenting what each of your loops is doing without having to use comments. Even if you don't use them in the execution itself. Just like good variable names avoid unnecessary comments.

    • @montebont
      @montebont Pƙed rokem

      Never thought of it that way but it sure makes sense. Thanks for sharing :-)

  • @RyanGralinski
    @RyanGralinski Pƙed 3 lety +1

    I love your videos, Ive been developing sites and software just as a hobby for over 25 years and been stuck in the old ways of doing things. I'm in the process of teaching myself angular and node and your videos are very helpful and easy to follow.

  • @aeronwolfe7072
    @aeronwolfe7072 Pƙed rokem

    new sub here, i absolutely LOVE your vids about 5 must know js features, and the other js video. GREAT CONTENT man! Thank you SO MUCH!

  • @maelstrom57
    @maelstrom57 Pƙed 3 lety +8

    these console methods are pretty neat, they sure'll make debugging a little less of a pain

  • @petarkolev6928
    @petarkolev6928 Pƙed 2 lety

    Kyle, amazing video, bro!!! Map & Set just changed my perception of how should I start working with objects and arrays :O

  • @njahncke
    @njahncke Pƙed 3 lety +1

    Thanks a ton for these videos man! Lots of awesome stuff in here.

  • @z-a3594
    @z-a3594 Pƙed 3 lety +9

    Note: You need unique ids when using console.time. Generate a random suffix for the name when using it in async functions that are called multiple times.

  • @IceMetalPunk
    @IceMetalPunk Pƙed 3 lety +2

    I often make a helper function to create "enums" in JS (obvs. not real enums, but close enough for most uses). It just takes a list of strings, and then returns a *frozen* object that maps the strings to Symbols of the string, thereby ensuring that (a) they can't be changed, and (b) they are all unique values. Which is like 2/3 of the use of enums.
    So for instance, I could do:
    const Directions = make_enum('UP', 'DOWN', 'LEFT', 'RIGHT');
    And the resulting frozen object would have unique symbols referenced as Directions.UP, Directions.DOWN, Directions.LEFT, and Directions.RIGHT.

  • @dean6046
    @dean6046 Pƙed 3 lety

    Thanks Kyle! Downloaded this to watch later. Keep up the good work.
    Constantine

  • @sanjitselvan5348
    @sanjitselvan5348 Pƙed 2 lety

    Man! Feature-packed video! Thanks so much!

  • @dave6012
    @dave6012 Pƙed 3 lety +22

    Thanks for all the great info! I hope your new courses make you enough money to finally afford furniture

    • @dave6012
      @dave6012 Pƙed 3 lety

      @@Jens-OS challenge? You son of a bitch, i’m in

  • @flaviocunha7576
    @flaviocunha7576 Pƙed 3 lety

    Most JS I learned in such small amount of time, You are amazing teacher !!!!

  • @jp0678
    @jp0678 Pƙed 3 lety +1

    Thanks for the loop label, console.assert, and console.table tips!

  • @anticsBack
    @anticsBack Pƙed 3 lety +54

    Another cool but rare piece of JS goodness: JS Proxy API.

    • @shr1han
      @shr1han Pƙed 3 lety +1

      I read somewhere that basic state management is possible using Proxy.

    • @microhoffman1248
      @microhoffman1248 Pƙed 3 lety +7

      Vue reactivity system is based on Proxies, if I am not mistaken. It's where I learnt first to use them :). They are really cool tho.

    • @lilspelunker5613
      @lilspelunker5613 Pƙed 3 lety

      @@microhoffman1248 Yup they are

    • @lilspelunker5613
      @lilspelunker5613 Pƙed 3 lety +19

      @@Jens-OS nah fuck off

    • @slowprogrammer
      @slowprogrammer Pƙed 3 lety

      Yaah😃

  • @mattd5419
    @mattd5419 Pƙed 3 lety +6

    When I work with large decimals I use .toFixed() with a + before to round and convert back to a number. Like this: `+num.toFixed(12)`

    • @tomg0
      @tomg0 Pƙed 3 lety +5

      @@Jens-OS reported for spam

  • @ventsislavstoimenov4404
    @ventsislavstoimenov4404 Pƙed 3 lety

    Man, this is simply amazing! Great content!

  • @doktordaxter
    @doktordaxter Pƙed 3 lety

    Very interesting stuff. I knew about some of these, but don't use it often. You explain it well and give good examples which makes it easy to understand, I will try to find use cases for these in my projects :)

  • @inordirection_
    @inordirection_ Pƙed 3 lety

    Those debugger tips are gonna be super useful! Thanks!

  • @elierh442
    @elierh442 Pƙed 3 lety

    wow, this is packed with stuff I did know existed! thank you for this!

  • @fvbixn
    @fvbixn Pƙed 3 lety

    Great video! I think I’m now officially a JavaScript Nerd, since I already knew all these features 😁

  • @spiderman955
    @spiderman955 Pƙed 2 lety +10

    For the loop variables: Is it not just easier and clearer to put the standard continue for i === 1 directly after the first for loop? This would directly increment the i counter.

    • @hnccox
      @hnccox Pƙed 2 lety +3

      I thought the same thing, but he probably just needed something easy to show of this example of this functionality.

    • @lucidattf
      @lucidattf Pƙed 2 lety

      yeah you dont need labels for this at all, labels arent really ever necessary but they can be good to know i guess

    • @JaekSean
      @JaekSean Pƙed 2 lety

      The point of this was to show the feature, not to show a practical example. This is a feature with a pretty rare use case. It's difficult to come up with a good example until you actually have a use for it

    • @purduetom90
      @purduetom90 Pƙed 2 lety

      These are glorified goto statements


    • @hunterwilhelm
      @hunterwilhelm Pƙed 2 lety

      @@purduetom90 I would make the case that break and continue are goto statements. But personally, I try not to use any for loops at all and use map filter and reduce instead

  • @Mitsunee_
    @Mitsunee_ Pƙed 3 lety +1

    well I definitely didn't know loop labels, so I guess this video actually wasn't clickbait, like all the other ones I've seen with a similar title :) good job!

  • @jorgeperez6752
    @jorgeperez6752 Pƙed 3 lety +1

    Great video as usual but the main question is, do you have a video or channel playing your Jackson?

  • @williamiiifarquhar4345
    @williamiiifarquhar4345 Pƙed 2 lety

    Thank you for this video! I definitely feel like I learned something new.

  • @keatonlee1157
    @keatonlee1157 Pƙed 2 lety

    I can't like this enough! I work in typescript every day and I have found so many incredible things from you.
    Holy crap you're a boss!

  • @danmc128
    @danmc128 Pƙed rokem

    The console and debugging stuff was fantastic, thanks for making my job easier!

  • @bradical8198
    @bradical8198 Pƙed 2 lety

    Exactly what @prometheas said below, I still reference your videos after all these years over any other video. You get to the point and you get to the point fast! A+ my man!

  • @rafagd
    @rafagd Pƙed 3 lety +2

    To properly deal with floating point precision errors caused by IEEE 754, you should write "Math.abs(a - b)

  • @ibgib
    @ibgib Pƙed 2 lety

    Great video! For me personally, the Set was the big win. I didn't realize that it was in ES6, but it makes creating a unique array muuuch easier without the need for an external library. Simply `[...new Set(array)]` or `Array.from(new Set(array))`. Of course this is only for primitives where value comparison is trivial! Thanks for the help 🙂

  • @thiagohencke7230
    @thiagohencke7230 Pƙed 3 lety

    Amazing features, didn't know some of them. Subscribed

  • @cryptoknight7256
    @cryptoknight7256 Pƙed 3 lety

    Great tips. Thanks, Kyle!

  • @defensivecybercoding
    @defensivecybercoding Pƙed 2 lety

    Excellent tutorial! Thanks for the help.

  • @schmaenjael
    @schmaenjael Pƙed 3 lety

    One of my favourite things in plain JavaScript is taking TypeScript features like an enum, an convert them to basic JavaScript. In that case, you can create an enum with
    const enumTest = Object.freeze({ test: "Hallo ich bin ein deutscher Text" )}
    export enumTest;
    you can now easily use this enum within your JavaScript files (you may wanna minify this code with babel and parcel, to also support older browsers like Internet Explorer);
    That's just one of the things I kinda like to do with JavaScript.

  • @swimtlvmitnovizki6895
    @swimtlvmitnovizki6895 Pƙed 3 lety

    I learn so much from your videos. Thank you for the effort you put into your work.

  • @AutisticThinker
    @AutisticThinker Pƙed 3 lety

    Awesome video as usual. I can't wait until you embrace TypeScript; I learn so much from your videos! :)

    • @WebDevSimplified
      @WebDevSimplified  Pƙed 3 lety +1

      I really want to dive back into Typescript this year.

  • @natiqmumtaz5309
    @natiqmumtaz5309 Pƙed 3 lety

    Great video, thanks Kyle ✌

  • @ferooref7614
    @ferooref7614 Pƙed 3 lety +1

    Highly appreciated, REALLY!

  • @user-oy4kf5wr8l
    @user-oy4kf5wr8l Pƙed 2 lety

    Amazing job, buddy! Amazing!

  • @tag9047
    @tag9047 Pƙed 3 lety +2

    A lot of this stuff is great with the exception of labels. Most likely you need to refactor some code to use a reducer if you are running nested loops.

  • @danieldilly
    @danieldilly Pƙed 3 lety +31

    In the first example, you could simply put your "if (i == 1)" statement within the first for loop. Problem solved.

    • @slowprogrammer
      @slowprogrammer Pƙed 3 lety

      â˜ș

    • @SealedKiller
      @SealedKiller Pƙed 3 lety +4

      Yeah I noticed this too. He was probably giving an example if you want to continue a loop within an another loop.

    • @jasonlai579
      @jasonlai579 Pƙed 2 lety +8

      I think "break" is also a good choice

    • @felipekazuoyatsu2
      @felipekazuoyatsu2 Pƙed 2 lety +3

      And way more readable

    • @kadensharpin2156
      @kadensharpin2156 Pƙed 2 lety +4

      generally in every possible situation there are much better solutions than using loop labels

  • @samisaacvicliph
    @samisaacvicliph Pƙed 2 lety

    Man! this should be sold on some learning platform for top dollars. So much valuable information here!! Thank you Kyle!

  • @MarlonEnglemam
    @MarlonEnglemam Pƙed 3 lety +6

    it's crazy how you apparently always shows some feature I'VE NEVER SEEN BEFORE! which is almost unbelievable to me since I've been around JS for a while lol!

    • @yadneshkhode3091
      @yadneshkhode3091 Pƙed 3 lety +1

      @@Jens-OS no

    • @arjix8738
      @arjix8738 Pƙed 3 lety

      believe me, all the features he is showing are handy, but not any better than what you already knew (in terms of difficulty)

    • @mohamedbasry9588
      @mohamedbasry9588 Pƙed 3 lety

      @marlon that indicates these features are useless

    • @MarlonEnglemam
      @MarlonEnglemam Pƙed 3 lety

      @@mohamedbasry9588 I've found many of theses features to be usefull actually! Of course, not all of them, but a lot!

  • @tcjusttc5418
    @tcjusttc5418 Pƙed 2 lety

    I love your vids!! High value

  • @ertugrul-bektik
    @ertugrul-bektik Pƙed 3 lety

    Thank you for tips. I really like them :)

  • @roncselloroni7854
    @roncselloroni7854 Pƙed 3 lety

    I love all your videos. I am just studying javascript, because I love this language 'console' languages. Thanks

  • @brianevans4
    @brianevans4 Pƙed 3 lety +27

    I have a video idea for you: do all the different Object methods such as Object.freeze Object.assign etc etc. I feel like I keep seeing new ones out in the wild

    • @botleydot
      @botleydot Pƙed 3 lety +1

      @@Jens-OS How about instead of commenting trying to appeal to people's kindness, you just make some good content?

  • @mob_abominator1868
    @mob_abominator1868 Pƙed 3 lety

    That last debugging part was insane, didn't know you could do so much with console.

  • @srinathsathyanath7435
    @srinathsathyanath7435 Pƙed 3 lety

    I think I should I checkout your js course👍 great bro

  • @dimaster5880
    @dimaster5880 Pƙed 3 lety +1

    Nice tips. Want to see your chrome dev tools tutorial...

  • @lawrencedoliveiro9104
    @lawrencedoliveiro9104 Pƙed 3 lety

    12:18 “for (k in «obj»)” loops over the keys in the object table. And you can have non-string keys in those, too.

  • @carloslema5400
    @carloslema5400 Pƙed 3 lety

    Pure gold. Thank you

  • @agbottan
    @agbottan Pƙed 3 lety

    Thanks! I learned some good stuff.

  • @bipolarmorgan
    @bipolarmorgan Pƙed rokem

    Quality information, thanks

  • @juhandvan
    @juhandvan Pƙed 3 lety

    exciting !!! Thanks very much !

  • @obinator9065
    @obinator9065 Pƙed 3 lety +4

    0:15 *then start using typescript*

  • @ayushsamantaray9868
    @ayushsamantaray9868 Pƙed 3 lety

    Thank you very much for the set function

  • @floflo-gr1iv
    @floflo-gr1iv Pƙed 3 lety

    Loved this, keep it up

  • @sskroller5276
    @sskroller5276 Pƙed 3 lety +2

    The labels work like in assembly that’s nice

    • @techgo4431
      @techgo4431 Pƙed 3 lety +1

      that's because that's where it comes from, labels are a relic of the old way of programming

  • @alexpro5670
    @alexpro5670 Pƙed 2 lety

    Cool, thanks for info!

  • @BugsNRoses_
    @BugsNRoses_ Pƙed 3 lety

    Thats some info kyle, i used to give colors to console log, just to get out from confused outputs, i wish i knew assert before,

  • @planetmall2
    @planetmall2 Pƙed 3 lety

    Great job!

  • @jimmyj.6792
    @jimmyj.6792 Pƙed 3 lety

    Really love your content and explaination 😍😍 you are so amazing thanks a lot for these awesome content

  • @johnkeck
    @johnkeck Pƙed 3 lety

    GREAT video!

  • @vaibhavyadav8726
    @vaibhavyadav8726 Pƙed 3 lety

    This video was really informative.

  • @nilsdannemann
    @nilsdannemann Pƙed 2 lety

    Wonderful, thank you

  • @Oblivianos
    @Oblivianos Pƙed 3 lety +26

    my opinion: in general avoid even recommending labeled lines of code to jump to. 'go to' is very easy to lead to spaghetti code and should not be recommended for novices.
    if you really need to use it first try to simplify your loop or even extract them or their contents into functions. i've seen plenty of times nested loops and conditions spiraling into a big mess even the original author couldn't understand what and why they did what they did a couple days later

    • @andrewmorton9683
      @andrewmorton9683 Pƙed 3 lety +3

      Indeed! The problem was famously pointed out back in 1968 by Edsger W. Dijkstra in an article titled "Go To Statement Considered Harmful".

    • @Diamonddrake
      @Diamonddrake Pƙed 3 lety +4

      Adding extra functions does nothing for nested loops and nested loops are a requirement for some algorithms. They are unavoidable. Labels have value and you should know about them.

    • @v01d_r34l1ty
      @v01d_r34l1ty Pƙed 3 lety +1

      This is what I’ve heard when I learned about goto in C++... but contrary to what everyone says, it can be used in ways that don’t spaghettify code. I know cuz I used it in a very unique and honestly rather efficient way back when I developed my CSGO hack. You can easily loop back to a certain part of an infinite loop when there’s complications with variables.

    • @lawrencedoliveiro9104
      @lawrencedoliveiro9104 Pƙed 3 lety

      I never use gotos at all. In languages like C, I typically need to manage dynamic objects anyway, to make sure they are properly disposed. This requires structured programming techniques, and the avoidance of gotos.
      I give some detailed examples here github.com/ldo/a_structured_discipline_of_programming .

    • @v01d_r34l1ty
      @v01d_r34l1ty Pƙed 3 lety

      @@lawrencedoliveiro9104 im not arguing that generally speaking you should avoid gotos im saying that they have their place even in well structured programs. the real use for them just isn't very common and generally a different structure would be preferred. my csgo hack's variables were dynamic and that's actually why i needed the goto over a traditional while/for loop or whatever. it was for the main fn.

  • @chefbennyj
    @chefbennyj Pƙed 2 lety

    Ah nest loops with labels. Sooo good. This is useful for looping through tv shows and their episodes. About the only time I would ever use a recursive nested loop. 😉

  • @joakimjohansson7729
    @joakimjohansson7729 Pƙed 3 lety

    I have when I have to mentally look at stuff 😂 Awesome video, learned a lot!

  • @harsh_vish
    @harsh_vish Pƙed 3 lety

    This video is very informative I did not know the power of javascript
    GREAT

  • @Berk45632
    @Berk45632 Pƙed 2 lety

    You debugged my entire life with that "debugger" keyword. Kyle, I luv ya so much.

  • @carneios08
    @carneios08 Pƙed 3 lety

    Didn't know about the console.assert(). Thanks for adding that to my logging arsenal.

  • @ben790924
    @ben790924 Pƙed 3 lety +3

    8:15 a handsome glance

  • @Ayomikun
    @Ayomikun Pƙed 3 lety +10

    Thanks as always, can think of a couple of situations where loop labels could've helped me a lot. Somehow feels like a bad practice thing that should be used rarely though

    • @ng429
      @ng429 Pƙed 3 lety +4

      if you find yourself in need of loop labels I can almost guarantee you have code that needs to be restructured anyway

    • @Voidstroyer
      @Voidstroyer Pƙed 3 lety

      @@ng429 I agree. loop labels are unnecessary if you know how to properly nest your loops (if nesting if necessary at all)

  • @eproulx
    @eproulx Pƙed 3 lety

    I believe the classic way to work around floating point issues is
    if(Math.abs(a-b) < Number.EPSILON)

  • @randomnobody660
    @randomnobody660 Pƙed 3 lety +1

    The labeling loops was very cool. TIL.
    With that said thou, isn't there something about messing up control flow? Otherwise we could just be using goto instead of increasingly fancy breaks and continues, or even mid-loop returns.

  • @pouriyanourouznejad7090
    @pouriyanourouznejad7090 Pƙed 2 lety

    Will "break" stop some Functions like interval or timeout? Or we can only use clearthem() to make them stop?

  • @silvgravity4492
    @silvgravity4492 Pƙed 3 lety

    Hey Kyle, is there any option to purchase just the advanced portion of the course? I already have a job as a full stack JS developer but I'd like to sharpen my skills with advanced knowledge

    • @WebDevSimplified
      @WebDevSimplified  Pƙed 3 lety +1

      Unfortunately that is not possible. It is only sold as a bundle.

  • @samuelwilson00
    @samuelwilson00 Pƙed 3 lety

    Very helpful information,đŸ‘đŸ». But please can you tell me how do I remove the index column in console.table()?

  • @KennyCarter90
    @KennyCarter90 Pƙed 3 lety

    These are amazing :O

  • @Grovion
    @Grovion Pƙed 3 lety +1

    The problem with 0.1+0.2 not equals 0.3 has been very very simplified in this video. Of course you can store 0.3 in binary. One not very effective but obviously possible solution would be as string. And some libraries that enables you to compute arbitrary big numbers (like BigDecimal in Java) do this. But since normally you want some nice compromise between precision, calculation speed and memory size, the primitive data types for floating point numbers are optimized for the most common use cases. They can store either pretty (but not alway perfect) accurate numbers or very big/very small numbers. But not both at the same time. So the real reason why most programming languages get 0.1+0.2 wrong is not, that if can't be represented in binary but that the representation used in most programming languages can't do it. Most programming languages (including JavaScript) use the IEEE 745 specification for storing floating point numbers. You can read all about it in the official specification (web.archive.org/web/20160806053349/www.csee.umbc.edu/~tsimo1/CMSC455/IEEE-754-2008.pdf ) or look on CZcams for some videos that explain in in a more digestible form since the specification is 70 pages long. Storing floating point numbers efficiently really isn't easy ;)

  • @snippedtiex
    @snippedtiex Pƙed 2 lety

    Echt hilfreich, danke

  • @mugavri
    @mugavri Pƙed 3 lety

    Very nice, thanks

  • @warheaven999
    @warheaven999 Pƙed 2 lety +1

    the problem with 0.1+0.2 is not only a computer problem. It's also a programmer problem. They forget to round to the same precision of the source numbers. If you have 1 digit on source, you must round to 1 digit on the result (for a addition), so you HAVE to round 0.3000000000004 to 0.3 to stay in the same précision level.

  • @sc12sc
    @sc12sc Pƙed 3 lety

    console.time is very useful, thanks !

  • @fufumitgemuese
    @fufumitgemuese Pƙed 3 lety +44

    "Almost Nobody Knows" is a huge overstatement ;)

    • @ChrisLocke1969
      @ChrisLocke1969 Pƙed 3 lety

      clickbait, damn arrogant millenials have NO CLUE what some of us know. Imagine them walking into a library to learn... lost like little puppies in the woods. Thanks youtube, for "dont show videos from this dick". 👍👍👍

    • @EidosGaming
      @EidosGaming Pƙed 3 lety +12

      @@ChrisLocke1969 what the fuck dude, this guy just tries to help people out. Plus it's true, the majority of web devs don't know these tricks. If you're a power user good for you but please don't spit on someone helping 90% of developpers out there

  • @danutzz8
    @danutzz8 Pƙed 3 lety

    Uau! great content Kyle ...

  • @gyorgyo7597
    @gyorgyo7597 Pƙed 3 lety

    Excellent video. Is it best to no longer use semi-colons?