3 Questions: You Don't Know JavaScript | Prime Reacts

แชร์
ฝัง
  • เผยแพร่เมื่อ 12 ก.ย. 2024
  • Recorded live on twitch, GET IN
    / theprimeagen
    frontendmaster....
    Reviewed video: • Test Your JavaScript K...
    By: Frontend Masters | / @frontendmasters
    MY MAIN YT CHANNEL: Has well edited engineering videos
    / theprimeagen
    Discord
    / discord
    Have something for me to read or react to?: / theprimeagenreact
    Kinesis Advantage 360: bit.ly/Prime-K...
    Hey I am sponsored by Turso, an edge database. I think they are pretty neet. Give them a try for free and if you want you can get a decent amount off (the free tier is the best (better than planetscale or any other))
    turso.tech/dee...

ความคิดเห็น • 331

  • @Eeezus1914
    @Eeezus1914 6 หลายเดือนก่อน +350

    lol the chat ate him alive for getting the first question wrong, meanwhile 80% of JS devs would also get it wrong.... the "senior netflix engineer btw" in the chat was gold lol

    • @davesomeone4059
      @davesomeone4059 6 หลายเดือนก่อน +42

      I'm glad he got it wrong. I feel better about getting it wrong too.

    • @neoqueto
      @neoqueto 6 หลายเดือนก่อน +25

      That question is the equivalent of "you drive a car? Name all the assembly plants where all the parts in your car were manufactured". Obviously you don't need to know that if you just want to drive a car. Unless that's why I still can't pass my driving exam...

    • @amotriuc
      @amotriuc 6 หลายเดือนก่อน +21

      The order question is stupid, if your code relies on that this order is maintained in order to work, your code is wrong. No wander not many know it.

    • @harmonicseries6582
      @harmonicseries6582 6 หลายเดือนก่อน +10

      80%? lol my bet is more than 95%

    • @saltytunes1883
      @saltytunes1883 6 หลายเดือนก่อน +8

      I don't think 80% of JS devs understood any of them

  • @elirane85
    @elirane85 6 หลายเดือนก่อน +250

    Every time I start to think I know javascript, I watch videos like this and realize how wrong I am

    • @KeremyJato
      @KeremyJato 6 หลายเดือนก่อน +16

      As a non-JS dev, reading this is horribly confusing; I'm glad I don't have to deal with this.

    • @neoqueto
      @neoqueto 6 หลายเดือนก่อน +3

      As someone who grew up with jQuery, I am screaming

    • @RetroGenetic
      @RetroGenetic 6 หลายเดือนก่อน +4

      @@KeremyJato there are 3 languages I hate, PHP, Java, and JavaScript. I can tolerate the last one, but it is mostly Hate Driven Development

    • @Linuxdirk
      @Linuxdirk 6 หลายเดือนก่อน +2

      Me too, and then I realize I just mess with it until it does what I expect it to do.

    • @ferinzz
      @ferinzz 5 หลายเดือนก่อน

      If it was just interpreted at runtime that would be one thing. The fact that you have to interpret whether it's a pointer or not is insane.

  • @3ventic
    @3ventic 6 หลายเดือนก่อน +203

    Things I learned from this:
    - Promise callbacks are microtasks, not tasks
    - "return" in generators is valid

    • @ThePrimeTimeagen
      @ThePrimeTimeagen  6 หลายเดือนก่อน +100

      return emotionally hurt me

    • @dealloc
      @dealloc 6 หลายเดือนก่อน +2

      @@ThePrimeTimeagen But ask yourself; why would you ever care about the value _after_ an iterator is already done, unless you manually handled the iteration?

    • @IMJamby
      @IMJamby 6 หลายเดือนก่อน +19

      "return" in generators is perfectly ok and I'd say a must: there are ton of problems where you want to early stop a generator. The issue is with "return " which is... odd.. at least.. A generator should yield values, and [eventually] end (return), it's not expected to return values.
      (btw, C# "solved" the ambiguity using "yield return " and "yield break" instead of reusing an existing keyword)

    • @oblivion_2852
      @oblivion_2852 6 หลายเดือนก่อน +4

      ​@@IMJambyyield break sounds like a nicer syntax than return.

    • @dave4148
      @dave4148 6 หลายเดือนก่อน +4

      @@IMJamby stop early you say? sounds like an exception to me -- python

  • @k98killer
    @k98killer 6 หลายเดือนก่อน +40

    I remember the days when EcmaScript didn't even have proper classes. Back in my day, we used functions named in PascalCase and then prefaced calls to them with the "new" keyword.

    • @jmfariasdev
      @jmfariasdev 6 หลายเดือนก่อน +2

      The so called and sometimes taught nowadays as "factory functions". Dude I had a huge clarifying moment last week when I finally decided to dive deep in understanding prototyping, inheritance and composition. Everything made sense afterwards, it was kinda of a cascade effect in my mind. But now I realize that javascript isn't well designed as some other languages.

    • @k98killer
      @k98killer 6 หลายเดือนก่อน +2

      @@jmfariasdev the inventor of JavaScript made it in just over a week iirc.

    • @jmfariasdev
      @jmfariasdev 6 หลายเดือนก่อน +1

      @k98killer people that architects and design programming languages are in another level that's for sure.

    • @k98killer
      @k98killer 6 หลายเดือนก่อน +2

      @@jmfariasdev It's just another thing that can be done well or poorly. Like anything else, it is a matter of learning from prior examples and then finding new ways to put ideas together.

  • @alastor--radiodemon7556
    @alastor--radiodemon7556 6 หลายเดือนก่อน +11

    "you don't know javascript"
    i know, i wanna keep it that way

    • @asmithdev2162
      @asmithdev2162 2 หลายเดือนก่อน

      Don't hate a language you aren't good at, it's fashionable to hate on JavaScript but it's a very powerful language when used properly

  • @ruroruro
    @ruroruro 6 หลายเดือนก่อน +31

    25:49 I think prime is wrong here. I am pretty sure that this is how generator functions work in almost every language. Remember that the end of the function has an implicit empty return. If returned values in generators were also included in the iteration, then this generator
    function* whatever() {
    for (const elem of ["fist", "second", "last"]) {
    yield elem
    }
    }
    would produce "first", "second", "last", undefined and to get the obviously intended results of "first", "second", "last" you would have to do something like
    function* whatever() {
    for (const elem of ["fist", "second", "last"]) {
    if (elem === "last") {
    return elem
    } else {
    yield elem
    }
    }
    }
    which is just ridiculously stupid

    • @Cmanorange
      @Cmanorange 6 หลายเดือนก่อน +1

      var ass = new Promise(() => whatever.next()).await //gachiHYPER

    • @martijn3151
      @martijn3151 6 หลายเดือนก่อน

      Comment above says it all 👌

    • @yyny0
      @yyny0 6 หลายเดือนก่อน

      Lua Coroutines don't do this. You would have to
      function whatever()
      coroutine.yield(1)
      coroutine.yield(2)
      return 3
      end
      or handle the final `nil`.

  • @user-uc6wo1lc7t
    @user-uc6wo1lc7t 6 หลายเดือนก่อน +36

    God, I was laughing so hard when he was wrong in the last question 😂

  • @MaybeADragon
    @MaybeADragon 6 หลายเดือนก่อน +187

    Every day I thank the lord for not learning Javascript as my first language (visual basic chads rise up)

    • @sdstorm
      @sdstorm 6 หลายเดือนก่อน +6

      Commodore Basic V2

    • @zokalyx
      @zokalyx 6 หลายเดือนก่อน +10

      python (normie first language but at least it's not js)

    • @Real-Name..Maqavoy
      @Real-Name..Maqavoy 6 หลายเดือนก่อน +1

      You and me both..!
      I hate .js and all the (copy-paste integraded) JS into other New ones.
      Creates a web of a
      mess and slow af code.

    • @somnvm37
      @somnvm37 6 หลายเดือนก่อน +2

      I started with VBS yeah, but after leanring a little bit (which was a lot for a 12yo)
      but the first real one was js? but not to well, and the first really learnt was python

    • @musashi542
      @musashi542 6 หลายเดือนก่อน +2

      same garbage @@zokalyx

  • @adjbutler
    @adjbutler 6 หลายเดือนก่อน +13

    GOTO considered harmful
    JS considered deadly and dangerous

  • @dipereira0123
    @dipereira0123 6 หลายเดือนก่อน +13

    Ok thats it! Im taking javascrip proficiency out of my CV. thanks!

  • @coder_117
    @coder_117 6 หลายเดือนก่อน +26

    Maybe I should learn Blazor & just run C# in the browser instead.

    • @josda1000
      @josda1000 6 หลายเดือนก่อน +3

      Bingo

    • @technolung
      @technolung 6 หลายเดือนก่อน

      Yes

  • @n4bb12
    @n4bb12 6 หลายเดือนก่อน +9

    More of these, that was fun!

  • @RandomGeometryDashStuff
    @RandomGeometryDashStuff 6 หลายเดือนก่อน +11

    20:20 javascript does have Option, it's constructor for html element

  • @sebastianwapniarski2077
    @sebastianwapniarski2077 6 หลายเดือนก่อน +4

    I actually switched smoothly from watching Anchorman 2 to Prime. The legend continues.

  • @_evillevi
    @_evillevi 6 หลายเดือนก่อน +7

    Lydia's slides are beautifully mind-blowing, does anyone know what she uses to make them?

    • @jackdixon6681
      @jackdixon6681 6 หลายเดือนก่อน +5

      Probably a computer 🤓💻

    • @SolidWorksMastery-hr4sg
      @SolidWorksMastery-hr4sg 6 หลายเดือนก่อน +1

      she use keynote ( i hear her answering your question once)

  • @rikschaaf
    @rikschaaf 6 หลายเดือนก่อน

    You know what would be interesting? A replay iterator that aside from next, return and throw also has a reset function. That way you don't have to keep a reference around to the original generator function. You can just reuse the current iterator. One that could also have niche usecases would be the caching replay iterator that, when reset, it doesn't have to recompute the original values, since it would have stored those values in a cache. That does defeat the purpose of generators somewhat, since they normally allow for a low memory footprint during iteration, but when caching you do still have that footprint. In such a case the only benefit would be is that you're fetching the values lazily, so you don't have to construct a full list of values before iterating over them.

  • @dae2530
    @dae2530 6 หลายเดือนก่อน +14

    1:35 I work with JS almost daily and I don't know what's the right order

    • @Bastanien
      @Bastanien 6 หลายเดือนก่อน +4

      If I was working with a codebase where knowing that order is necessary to maintain or debug it, I'd seriously reconsider my life choices.

    • @ivrtaric
      @ivrtaric 6 หลายเดือนก่อน

      Here's a hot take: HOW OFTEN in your day-to-day work do you need to know in which order these will execute? I mean, yes, you need to know there IS an event loop, and that there are certain steps within that loop that execute in a certain order, but how often do you need to KNOW THE EXACT order, or even ALL of the steps that execute within an event loop cycle? I mean, in the rare event that you do need to debug these (and that's when you run into a mix of setTimeout(..., 0) and setImmediate and Promise.resolve()), it shouldn't be that hard to google it out?
      Seriously, questions like that remind me of a meme about the Mendeleev's periodic table of elements, which he created specifically so that chemists DIDN'T need to memorize all the data about the elements, and then you get school teachers who FORCE the students to memorize it... -_-

  • @tylermfdurden
    @tylermfdurden 6 หลายเดือนก่อน +7

    my_obj.__proto__ = "We're all adults here, I can modify whatever I want"

  • @arcoute9108
    @arcoute9108 6 หลายเดือนก่อน +59

    Thank god I write C

    • @tollmlg7852
      @tollmlg7852 6 หลายเดือนก่อน +26

      Finally, a safe language.

    • @TheOnlyJura
      @TheOnlyJura 6 หลายเดือนก่อน +3

      wish I could find a job in C

    • @simpingsyndrome
      @simpingsyndrome 6 หลายเดือนก่อน

      Rust us rusty though!

    • @spicybaguette7706
      @spicybaguette7706 6 หลายเดือนก่อน +1

      Because C has no footguns at all

    • @TheOnlyJura
      @TheOnlyJura 6 หลายเดือนก่อน

      @@spicybaguette7706 it does, but they are much more reasonable

  • @ISKLEMMI
    @ISKLEMMI 6 หลายเดือนก่อน +1

    This was fun!
    IIFE - Immediately invoked function expression. I've heard it pronounced 'iffy' most of the time.
    11:49 - I've definitely modified a few built-in prototypes in order to get Vue2 to work in an HTML Application / .hta file. mshta.exe uses an ancient JavaScript engine, so some monkey patching was absolutely required to get things to work at all.

  • @wi1h
    @wi1h 6 หลายเดือนก่อน +4

    22:46 prime liking for await makes so much sense when you consider that he used to work with a lot of rxjs

  • @size_t
    @size_t 6 หลายเดือนก่อน +11

    1:56 - looking at this, tells me: JS, you're drunk. Go home!

  • @FanatiQS
    @FanatiQS 6 หลายเดือนก่อน

    Extra info about question 1. The prints for 4, 5 and 6 are sync in the javascript engine while 1 is queued in the engine. 5 is not implemented in the engine (not ecmascript) but still queues on the engines task queue. The setTimeout callback is added to the runtimes event loop and would not work at all in a pure javascript engine evaluation (it is a webAPI that requires a runtime). Writing my own super basic javascript runtime in C was great for learning how javascript runtimes work.

  • @asdjzcx2619
    @asdjzcx2619 6 หลายเดือนก่อน +17

    Senior dev vs junior interview questions

  • @n8ged8
    @n8ged8 6 หลายเดือนก่อน +1

    A coding language is just like a spoken language - go with the flow and learn and use what's necessary and useful in your situation but you don't have to learn complete dictionaries or grammar books which makes you a bit better but it's not worth the effort - you soon forget all that you don't use in real world! That's why you have to repeat vocabulary a lot when you want to learn efficiently. Save yourself time and get started with real problems you want to solve - one after another! That's how you get better in coding!

  • @gfdgdfgdfgdfggfdgdfgdfgdfg9709
    @gfdgdfgdfgdfggfdgdfgdfgdfg9709 6 หลายเดือนก่อน +6

    About question 1, we hired a guy once that wrote code like that with resolves, classes, pipes and stuff like that there. I removed all those stupid tools with procedural js and the programm worked 12 times faster. Instead of taking 2 minutes to create the same content it now takes 10 seconds. So I consider using that stuff bad practice and honestly very bad coding. I understand that it should help you with bigger programs. But if you program gets 12 times slower because of crap like that it's a dead end. I come from game developement and crap non game "master" programmers use would never fly on my board,

  • @acharris
    @acharris 6 หลายเดือนก่อน +2

    Javascript has an exponential learning curve

  • @AdamHoelscher
    @AdamHoelscher 6 หลายเดือนก่อน

    The iterator example has the same behavior in Python. If you return a value from a Python generator that value is part of the StopIteration error.
    There's also a similarity in Go's channels; each read from a channel gives back a value and a bool that says whether the channel is still open. When you range a Go channel it returns a 0, false and the false breaks the loop.

  • @rodrigolj
    @rodrigolj 6 หลายเดือนก่อน +2

    JavaScript is like government bureaucracy: everybody depends on it, but nobody really understands it.

  • @huge_letters
    @huge_letters 6 หลายเดือนก่อน +1

    Regarding the second question - not everything outside of constructor is added to the prototype, only method declarations.
    Try defining any property like
    class A{
    myarrow = () => 1
    myprop = {}
    myfunc = function(){}
    mymethod(){} // this will be on prototype
    }
    they're gonna be different for each instance. this is pretty obvious for objects and arrow functions especially - would be wild if that object was shared and how would this binding even work on each instance if it's shared?

    • @TurtleKwitty
      @TurtleKwitty 6 หลายเดือนก่อน

      It just wouldn't have a bound this simple

  • @boi6514
    @boi6514 6 หลายเดือนก่อน +1

    The first one is literally the same question I give to all folks on interviews lol.

  • @RobRoss
    @RobRoss 6 หลายเดือนก่อน +5

    Looks like a taxonomic evolutionary hierarchy. If this is the case, Wolf should extend Canine and Dog should extend Wolf. Although I would not build a class hierarchy like this in code. It’s too brittle. What if we discover at some point that dogs don’t descend from Wolves but some other canine ancestor?

    • @poolkrooni
      @poolkrooni 6 หลายเดือนก่อน +2

      Sooo what if we discover dogs aren't canine? In a world of what ifs you won't get anything done

  • @PieJee1
    @PieJee1 6 หลายเดือนก่อน

    the first question. setTimeout with 0 responds differently in every browser when used in combination with promises. Well I can remember it was IE that did it different from the other browsers.

  • @MenkoDany
    @MenkoDany 6 หลายเดือนก่อน +1

    Man I'm glad I don't have to do JS professionally anymore. My guesses were: 4, 5, 6, 2, 3, 1; A: true, B: false, C: true, D: (hesitated) true, E: true; (so same as prime); I hesitated and picked E
    The explanations by Lydia were awesome by the way, I was skeptical at first expecting a wikihow-level video

  • @kuhluhOG
    @kuhluhOG 6 หลายเดือนก่อน +2

    As someone who barely knows JavaScript (straight up because I never use it), I learned a few things:
    1. There are multiple event queues (microtasks and macrotasks). Why? No idea, but they exists.
    2. That you should only use 'return' when using generators in JavaScript because of the way they work.

    • @copperspartan1643
      @copperspartan1643 6 หลายเดือนก่อน

      It’s such a ghastly language. I’ve had to dive into it from time to time over the years, but do the minimum I need and get out.

    • @kuhluhOG
      @kuhluhOG 6 หลายเดือนก่อน

      @@nisonaticthanks for the explanation
      and this smells more like a hack than an actual solution

  • @ProfRoxas
    @ProfRoxas 6 หลายเดือนก่อน +3

    I dont have much JS experience and async will always be my bane in any language possible, therefore i failed the first miserably.
    The second was actually simple, just know what points where.
    Third I only knew because That's what she said! She already shown it and I'll refuse to accept it as logical.

    • @ThePrimeTimeagen
      @ThePrimeTimeagen  6 หลายเดือนก่อน +3

      you pretty much had my thought process on 2 and 3
      2 easy
      3 i know she said it, but i refuse to believe it

  • @jonathan-._.-
    @jonathan-._.- 6 หลายเดือนก่อน +3

    oO i went completly overboardwith the contructor analysis : thinking stuff like: but once its instantiated it may be bound to the new this object or whatever :D

    • @GrantGryczan
      @GrantGryczan 6 หลายเดือนก่อน

      Binding is done on the fly! That allows a lot more memory saving

  • @n8ged8
    @n8ged8 6 หลายเดือนก่อน

    @24:18 In the example there's an output in the middle with comment on the right "// [1, 2, 3]" without "4" so the return statement is not returning a value (which sounds silly). I heard about generators, never used them, forgot about them but here I was right (because of the example). :-)

  • @wilkyarny3012
    @wilkyarny3012 6 หลายเดือนก่อน +1

    Feeling less alone with my skill issues

  • @proosee
    @proosee 6 หลายเดือนก่อน +1

    Breathable interface ironically killed me XD

  • @zwerko
    @zwerko 6 หลายเดือนก่อน +1

    Haven't been playing with JS for a long, long time... I see it now has generators and a semi-decent event loop, glad it picked up some cues from more competent languages, like Python. *_*hides*_*

  • @CocoaPimper
    @CocoaPimper 6 หลายเดือนก่อน

    Even with optionals a generator function could not simply return “nil” when it’s done because generators can yield undefined, null and a hypothetical Optional.nil value.

  • @Euphorya
    @Euphorya 6 หลายเดือนก่อน +10

    How does anybody use JS without going insane? The amount of implicit knowledge required to follow JS code is bonkers.

    • @SXsoft99
      @SXsoft99 6 หลายเดือนก่อน +1

      it's just a language with it's own particularities, every language has it's own

    • @f.b.1665
      @f.b.1665 6 หลายเดือนก่อน +5

      @@SXsoft99I mean you're right, JS just feels like it has especially many of them. Sometimes it's like a series of particularities that somehow ended up being turing complete. 💀

    • @TurtleKwitty
      @TurtleKwitty 6 หลายเดือนก่อน +1

      Most of this stuff doenst come up that often, and when it does the fact that js can log entire objects with functions and everything make it pretty easy to see where the failing in understanding ofthe final state is

    • @andreilucasgoncalves1416
      @andreilucasgoncalves1416 6 หลายเดือนก่อน +2

      I work with full stack TS for 8 years and sometimes I really regret working with it and it's usually related to complex build step and not the language itself
      When I am going insane I take a break, do other stuff

  • @blackAngel88it
    @blackAngel88it 5 หลายเดือนก่อน +1

    The worst part about the generator one:
    when you have yield 1; yield 2; return 3; you actually get
    it.next(); //1
    it.next(); //2
    it.next(); //3
    but when you do
    [...it]; //1, 2
    it.next() // undefined
    Why does one go to 3 and the other one only to 2? Guess it still calls next() again, doesn't yield but returns, so it is done and the 3 disappears into thin air? Weird... either return (different from undefined) should not be allowed or it should behave the same way... 🤷‍♂

  • @Real-Name..Maqavoy
    @Real-Name..Maqavoy 6 หลายเดือนก่อน +15

    Everyone: *JS is Awesome for coding!*
    Me: *Can I kill it now?*

  • @Voidstroyer
    @Voidstroyer 6 หลายเดือนก่อน

    The last one is weird in the sense that manually calling count() will give you all 3 values. Only when value === 3, done === true. Which is not consistent with using [...it] or for of. It's the inconsistency that is the problem. Manually calling next() respects the return value, while using the other 2 methods does not.

  • @pavloburyanov5842
    @pavloburyanov5842 6 หลายเดือนก่อน +1

    without strong understanding nature of promises - its pain in the ass) but its not so hard, just 1 day of digging helps me a lot

  • @blenderpanzi
    @blenderpanzi 6 หลายเดือนก่อน +2

    AFAIK there's no setTimeout() of 0 ms, it's rounded up to 50 or something. For security reasons or something.

    • @dealloc
      @dealloc 6 หลายเดือนก่อน +2

      It's not specified by spec, but some browsers/engines will add additional random time to the timeouts to mitigate Spectre attacks. Though, this can be disabled and it's not an important part of the question itself.

    • @blenderpanzi
      @blenderpanzi 6 หลายเดือนก่อน

      @@dealloc Well, I guess anything >6 will make it last out if those no matter what.

    • @dealloc
      @dealloc 6 หลายเดือนก่อน

      @@blenderpanzi It's not important to the question, because its a general question about the expected behaviour, given that you know the spec; not the internal workings of specific browsers and the random value that determines the timeout.

  • @valintepes
    @valintepes 6 หลายเดือนก่อน +1

    I worked on code like q1 for 2 years. I don't understand still.

  • @SeRoShadow
    @SeRoShadow 6 หลายเดือนก่อน +4

    Just tried a few generator function, or better Iterators .
    Why would you return a value from Iterators.
    Adding a "return" value looks like a bad practice, since it confused even a senior.

  • @nickharbinger6839
    @nickharbinger6839 6 หลายเดือนก่อน +1

    Hyenas are actually part of the larger cat family not canines as odd as that seems looking at them.

  • @harsha1306
    @harsha1306 5 หลายเดือนก่อน

    You know it gonna be a nice spicy react when the video is nearly 3x the size of the original video 😩👌🔥

  • @grumpylibrarian
    @grumpylibrarian 6 หลายเดือนก่อน

    I create massive amounts of Node code with async generator functions. Chain them together for cool on cruise control.

  • @fuzzy-02
    @fuzzy-02 6 หลายเดือนก่อน +1

    This Lydia didn't carry my burdens

  • @Tony-Red
    @Tony-Red 6 หลายเดือนก่อน

    "Hi, I'm Lydia"
    Prime: ~pause video~ "I really want"

  • @ib_concept
    @ib_concept 6 หลายเดือนก่อน

    all for loops initialize from outside(where the counter starts) and iterate on the inside, similar to slicing :: ``` include:exclude
    ```

  • @aboubakarycisse8138
    @aboubakarycisse8138 6 หลายเดือนก่อน

    Generator work the same way in PHP except that in PHP you can get the return value if you want by calling a specific method. I don't know how it work in other languages

  • @warrenprezydent2010
    @warrenprezydent2010 6 หลายเดือนก่อน

    I''ve used generators for writing scripts. I needed to fetch all pages from OKTA and on every page perform some actions. Generator was a clean way on performing that. Obviously I could put it inside a loop but c'mon, I am a functional BRO

  • @Tobsson
    @Tobsson 6 หลายเดือนก่อน +13

    I do react by day, and I've used settimeout, 0 more then once since state changes are put on a schedule and I needed to push the call to the end of the macrotask so that the state would update before the call is done. React is stupid. JS is stupid. I hate the js scheduler.

    • @dealloc
      @dealloc 6 หลายเดือนก่อน +7

      That's smells to me that you are not syncing your state with your rendering. Which can be perfectly viable if you rely on DOM mutations _after_ a commit (for one reason or another) for but no other reason really.

    • @mks-h
      @mks-h 6 หลายเดือนก่อน +1

      honestly, I'm not sure you're doing this right

    • @Tobsson
      @Tobsson 6 หลายเดือนก่อน

      @@dealloc I'm sorry. I was really unclear to what I'm doing. I use settimeout to push the queue around to figure out the flow. I don't leave a bunch of settimeouts in the code.

    • @dealloc
      @dealloc 6 หลายเดือนก่อน

      @@Tobsson Yes, but the only reason why you'd do that is 1) your flow is not well-defined, and 2) if in React, is due to not being in sync with React rendering, by doing work outside React's lifecycle.

    • @Tobsson
      @Tobsson 6 หลายเดือนก่อน

      @@dealloc defined? It becomes defined when it works as expected. 😂

  • @kriffos
    @kriffos 6 หลายเดือนก่อน +1

    Question 2 D, the solution is right but the explanation is wrong. The prototype is Dog not Object, as you have two instances of the prototype Dog.

  • @sk-sm9sh
    @sk-sm9sh 6 หลายเดือนก่อน

    Generators are first class in v8 long before async/await arrived. For several years people were using generators to achieve async/await style code.

    • @AlexWerner42
      @AlexWerner42 6 หลายเดือนก่อน

      I remember the require('bluebird') times, I still failed the test. Somehow, a new stack has emerged (micro/macro) from my POV, with the chat even saying animation queue too ?
      I think spending so much time and energy delivering and learning tools, services, devops etc etc... makes us not having time to even learn that much of the language :x

  • @mks-h
    @mks-h 6 หลายเดือนก่อน +6

    Hot take: If anyone, those who pass the first question should be fired. Because if you know about that kind of almost-defined behavior, you may actually rely on it - which is likely the worst that could happen to your codebase.
    That being said, now we are all fired

    • @todd.mitchell
      @todd.mitchell 6 หลายเดือนก่อน +2

      Exactly.

    • @codeChuck
      @codeChuck 5 หลายเดือนก่อน

      You are very correct about the relying on it! It was different order in different browsers as I recall. Do not know if this is fixed and standardized now.

  • @AlexanderCerutti
    @AlexanderCerutti 6 หลายเดือนก่อน

    15:02 he became a Believer 💀

  • @realcundo
    @realcundo 6 หลายเดือนก่อน +1

    Not being a JS/Node dev: is the order/behaviour specific to the V8, is it guaranteed that other engines would behave the same way?

    • @dealloc
      @dealloc 6 หลายเดือนก่อน +5

      Yes. It's by spec. If an engine does it differently, file a bug report!

    • @codeChuck
      @codeChuck 5 หลายเดือนก่อน

      You are correct, at least in the past. Previously it had different order in different browsers. Need to check how is it now.

  • @somnolence5339
    @somnolence5339 6 หลายเดือนก่อน +3

    Ever wondered how all this would look if IE vbscript won over Netscape javascript instead? :)

  • @AndreGreeff
    @AndreGreeff 3 หลายเดือนก่อน

    "why is that valid? I don't know, that's just what happened in the 7-day cocain rage that was javascript's birthing." classic Prime.

  • @Dystisis
    @Dystisis 6 หลายเดือนก่อน +1

    Naming my class Prototype

  • @paw565
    @paw565 6 หลายเดือนก่อน +2

    I mean who cares, you just have to know how to get shit done and not which console log will be first lol

  • @coolworx
    @coolworx 5 หลายเดือนก่อน

    Modifying the prototype is like dropping acid.
    Not for everyone.

  • @XDarkGreyX
    @XDarkGreyX 6 หลายเดือนก่อน

    I barely use promises and async... Glad I got one right for the first task.

  • @Omar-sr1ln
    @Omar-sr1ln 5 หลายเดือนก่อน

    its coming out as we speak

  • @rcoder01
    @rcoder01 6 หลายเดือนก่อน

    Seeing that js doesn’t include the return value in the generator makes me prefer python’s exception-as-end generator model

  • @titos2k
    @titos2k 6 หลายเดือนก่อน

    speaking of chat that doesn't work - here's an idea for a webapp: GPT-fed fake chat (100+ users) that responds to microphone input with some delay.

  • @NoFailer
    @NoFailer 6 หลายเดือนก่อน

    JavaScript is like English (as a second language) to me. I can use it perfectly fine with what I have learned even if I haven't learned everything there is to learn.

  • @gfdgdfgdfgdfggfdgdfgdfgdfg9709
    @gfdgdfgdfgdfggfdgdfgdfgdfg9709 6 หลายเดือนก่อน +2

    Honestly the most interesting thing in Javascript for me was how to figure out if a value is NaN. Like if var a = Number("abc"); To figure out if a is NaN in JS this is the solution:
    a != a (true) Only nan is not equal to itself in JS. This is so funny, because they have to make sure there will never be another thing in js that is not equal to itself otherwise NaN detection will be impossible.

    • @ivrtaric
      @ivrtaric 6 หลายเดือนก่อน

      OTOH, you know, Number.isNaN() exists now. And isNaN() (not a static Number function, but a global one) has existed for quite some time now. :shrug:

    • @the-answer-is-42
      @the-answer-is-42 6 หลายเดือนก่อน +1

      This is not a JS thing iirc, it's due to how floating point numbers work. Any language that has floats should work the same way.
      Think the idea is that NaN is just Not a Number, which means it can be anything that's not a number and thus should not equal itself because we don't know if it's a string or a zebra.
      Not saying I agree, it's just the motivation I heard (don't know if it's true or not either, so please correct me if I'm wrong).

    • @gfdgdfgdfgdfggfdgdfgdfgdfg9709
      @gfdgdfgdfgdfggfdgdfgdfgdfg9709 6 หลายเดือนก่อน +1

      @@the-answer-is-42 Now that I think about it, I wonder if String(NaN) == "NaN" would work too. Though it's too uncool for me to check compared to NaN != NaN. And what you are saying is that the answer is not 42 but maybe a string or a zebra. While I never worn a string I gotta say strings do look hot

  • @Kane0123
    @Kane0123 6 หลายเดือนก่อน

    Thought some drum and bass had started after a previous video…

  • @johnathanrhoades7751
    @johnathanrhoades7751 3 หลายเดือนก่อน

    Lydia is so good at this!

  • @user-pw5do6tu7i
    @user-pw5do6tu7i 6 หลายเดือนก่อน

    Here is another test. The key question is "does 3 resolve before 2?". (result in reply):
    console.log(1)
    setTimeout(() => {
    console.log(2)
    }, 1);
    //SomeLongFunction
    let a = 0;
    for(let i = 0; i < 1_000_000_000; i++){
    a += 1;
    }
    setTimeout(() => {
    console.log(3)
    }, 0);
    //SomeLongFunction
    let b = 0;
    for(let i = 0; i < 1_000_000_000; i++){
    b += 1;
    }
    console.log(4)

    • @user-pw5do6tu7i
      @user-pw5do6tu7i 6 หลายเดือนก่อน

      in chrome I get 1-4-3-2

  • @SolarPlayer
    @SolarPlayer 6 หลายเดือนก่อน +2

    JS gigabrains flexing they can overcome any handicap. Back to easy C for me

  • @dabbopabblo
    @dabbopabblo 6 หลายเดือนก่อน

    People like her remind me how much I have left to learn

  • @adjbutler
    @adjbutler 6 หลายเดือนก่อน

    generators are great memory savers

  • @sefumies
    @sefumies 6 หลายเดือนก่อน

    SetTimeout is put on the callback queue

  • @KushMastaFresh
    @KushMastaFresh 5 หลายเดือนก่อน

    Yoooo, is that a Russian River Brewery jacket!?!?!

  • @archmad
    @archmad 6 หลายเดือนก่อน

    How cqn you missed the last one. She literally said only the yield will return

  • @c4tubo
    @c4tubo 6 หลายเดือนก่อน

    Even more hilarious is that generator "functions" (a terrible name to call an object with shared mutable state) were added to ECMA in 2015. So there is no excuse of this being tossed into JS at its creation as a trivial web scripting language that was never intended to support programming at the scale it is now. Someone thinks this is a cool language feature.

  • @AqoCyrale
    @AqoCyrale 5 หลายเดือนก่อน

    please make more videos like this

  • @KangoV
    @KangoV 6 หลายเดือนก่อน

    I'm confused. If you create a promise and do nothing else, the provided function will not run? (5) So, a promise is not lazy/deferred? Wow! And people say Java is bad LOL!

  • @pick6and129
    @pick6and129 6 หลายเดือนก่อน

    I'm gonna stick to memorizing the ABC's. I"m up to Q and feeling confident.

  • @meetzaveri734
    @meetzaveri734 6 หลายเดือนก่อน

    don't get puzzled by the looks of setTimeout( ...whatever, 0) (emphasis on zero)

  • @sonicjoy2002
    @sonicjoy2002 4 หลายเดือนก่อน

    Turns out you are always learning JavaScript, the learning is never done.

  • @jamlie977
    @jamlie977 6 หลายเดือนก่อน +1

    javascript, i love it

  • @moonasha
    @moonasha 6 หลายเดือนก่อน

    fun fact: the james webb space telescope runs on javascript.

    • @XDarkGreyX
      @XDarkGreyX 6 หลายเดือนก่อน

      "Fun"
      Fcking hell....
      How did we end up here.

  • @lgasc
    @lgasc 5 หลายเดือนก่อน

    Why do JavaScript have _two_ event queues?

  • @harsha1306
    @harsha1306 5 หลายเดือนก่อน

    5 minutes in and I already want to give up and go all in on HTMX

  • @amekudzilab
    @amekudzilab 5 หลายเดือนก่อน

    What's the name of the font she is using?
    Anyone?

  • @Dylan_thebrand_slayer_Mulveiny
    @Dylan_thebrand_slayer_Mulveiny 5 หลายเดือนก่อน

    1/3. Ouch, I'm glad I don't own netflix stock.

  • @cthecheese1620
    @cthecheese1620 6 หลายเดือนก่อน

    08:15 is a vulnerability waiting to happen

  • @popcorn245
    @popcorn245 6 หลายเดือนก่อน +1

    "Why is that valid, I dunno, that's just what happened in the 7 day cocaine rage that was JavaScript's birthing."
    - The Primeagen

  • @olagarto1917
    @olagarto1917 6 หลายเดือนก่อน

    i dont get obgects, the more i try to learn theyr value the worst the examples get

  • @Dominik-K
    @Dominik-K 6 หลายเดือนก่อน

    This was pretty fun

    • @jt-moneyHockey
      @jt-moneyHockey 5 หลายเดือนก่อน

      it was humiliating