ex-FAANG Developer vs "Impossible" JavaScript Quiz

Sdílet
Vložit
  • čas přidán 24. 03. 2024
  • How well do I know JavaScript? Let's find out with this supposedly impossible JavaScript quiz!
    JavaScript Quiz: javascriptquiz.com/
    Prepping for your frontend interviews? Use code "conner" for a discount on my product FrontendExpert:
    www.frontendexpert.io/conner
    🎬 TikTok: / connerardman
    💼 LinkedIn: / connerardman
    💻 Video/Coding Gear (affiliate): www.amazon.com/shop/connerardman
    Business/brands 👉 youtube@connerardman.com
  • Věda a technologie

Komentáře • 121

  • @ThePrimeTimeagen
    @ThePrimeTimeagen Před 4 měsíci +453

    i got them all right and got immediately hired by a FAANG company

  • @brandonkellner2920
    @brandonkellner2920 Před 4 měsíci +107

    So [] == 0 == false if it's a number, and [] == true if it's a boolean, that makes a lot of sense. Thanks, javascript.

    • @eugeneponomarov7429
      @eugeneponomarov7429 Před 3 měsíci +5

      Empty array is evaluated the same way as empty object in js - it just substitutes the object/array with reference to heap (like 0xFFFFFFFFFFFF) which is true.
      But Number([]) is super weird and makes no sense. Well, this code makes no sense, so why the result should make sense...

    • @brandonkellner2920
      @brandonkellner2920 Před 3 měsíci

      @@eugeneponomarov7429 Interesting. I don't write javascript, so I had no idea why it would work that way.

    • @GBOAC
      @GBOAC Před 3 měsíci +1

      @@eugeneponomarov7429because determinism should be separate from the subjective perception of something making sense or not.

  • @matts154
    @matts154 Před 4 měsíci +52

    While this quiz is a fun way to test of your knowledge of Javascript, these scenarios are why we have "use strict" and linting rules.

  • @andreikhotko5206
    @andreikhotko5206 Před 4 měsíci +46

    I see 1 good use case for String.raw: defining a string variable containing backslashes. For example, windows filepath. String.raw`D:\path\to\file`, which is more readable than "D:\\path\\to\\file". This can be applicable to any string value containing backslashes which you don't want to escape everytime. It can be even inlined SQL script which can contain string literals (not a good idea, but anyway)

    • @wntiv
      @wntiv Před 4 měsíci +7

      personally was thinking with regex, if you needed to use the constructor (for whatever reason), which takes the representation of the regex *as a string*, in which you would have to double-escape any special chars (e.g. \d -> "\\d"). This would not be necessary using String.raw.

    • @cameronball3998
      @cameronball3998 Před 4 měsíci +2

      exactly. i’ve used raw strings all the time for defining static regex in python code. e.g., `r’my raw
      string’`

    • @soniablanche5672
      @soniablanche5672 Před 4 měsíci

      Yep. I have a script that uses String.raw to store a Windows path in a variable.

    • @joshix833
      @joshix833 Před 3 měsíci

      Just use slashes for paths. Why would one use backslashes?

    • @cameronball3998
      @cameronball3998 Před 3 měsíci +2

      @@joshix833 windows’ path separator is the backslash; it’s necessary to use to delimit a path on windows

  • @BeccaYetiammo
    @BeccaYetiammo Před 3 měsíci +4

    10:18 I haven’t heard of String.raw in JS but there is a similar feature in Dart. One use case for them is declaring regular expression string literals. You don’t have to deal with escaping certain characters etc.

  • @bobcoleman2920
    @bobcoleman2920 Před 4 měsíci +2

    I recently used a version of String.raw in C# where instead you use the @ symbol before the string (string myString = @"my string contains "quotes" and stuff"), and this was for adding a SQL Server connection string to my app, so instead of using \ before the " to consider it part of the string itself, you use the raw value of the string which is everything contained within the outermost quotes

  • @benl9878
    @benl9878 Před 3 měsíci +4

    love when people bring up they are a former faang employee. i don't bring up that I use to bag groceries at kroger.

    • @ConnerArdman
      @ConnerArdman  Před 3 měsíci +3

      Much like crossfitters, we are contractually obligated to bring it up at all possible moments

  • @Q_20
    @Q_20 Před 4 měsíci +1

    String.raw is useful with creating regular expression dynamically

  • @yega3k
    @yega3k Před 4 měsíci +19

    This is why I hate dynamic languages (a little 😅)

    • @foo0815
      @foo0815 Před 4 měsíci +13

      Dynamic languages are ok, automatic type conversion isn't.

    • @stefanalecu9532
      @stefanalecu9532 Před 4 měsíci +4

      Are you really projecting your hate towards JS onto other dynamic languages? Python doesn't have this skill issue, for instance

    • @yega3k
      @yega3k Před 4 měsíci +1

      It’s an issue that can only happen in a dynamic language because it has to do some kind of type “guessing” since your types are not explicitly defined. I’m learning Elixir right now and I also don’t like the “ambiguity” of type sometimes - like having a list of mixed types. So it’s not just JS (although JS could be the worst offender).
      That said, I still use JS and Python and as mentioned I’m learning Elixir - another dynamic language so no need to get defensive 😉

    • @yega3k
      @yega3k Před 4 měsíci +1

      I take back my previous reply. Automatic type conversion does make a big difference.

    • @AbbyChau
      @AbbyChau Před 4 měsíci +1

      just blame JS. the rules are so messy.

  • @schwidola3549
    @schwidola3549 Před 4 měsíci +1

    Looks like useful knowledge to debug weird code that some co-worker might have written, if they didn’t know those pitfalls 😅

  • @user-hr7wl8xr7o
    @user-hr7wl8xr7o Před 3 měsíci

    String.raw is pretty useful when you work with windows-like path in Node.js

  • @acirinelli
    @acirinelli Před 3 měsíci

    Floating point arithmetic caused me so many problems until I learned about it. Switched to all integers and convert to decimals.

  • @borjinator
    @borjinator Před 4 měsíci +3

    I surpringly got all correct except number cast of empty array in question 7

  • @elgeempire493
    @elgeempire493 Před 25 dny

    First time i see your channel look really cool

  • @ExpensivePizza
    @ExpensivePizza Před 3 měsíci +1

    It's actually insane that we ended up on the timeline where JavaScript exists.

  • @RayBellis
    @RayBellis Před 3 měsíci

    9/10, and only because I was fooled by the correct answer for `typeof NaN` not having string quotes around it so I had ruled it out.

  • @Fishpizza1212
    @Fishpizza1212 Před 3 měsíci +1

    For the floating point precision problem: Does JavaScript give you standard library tools to deal with errors in floats?
    I'm just wondering because in other languages, like Rust or C, you can just cast 0.1 and 0.2 as f32 (Rust) or float (C) which then is equal to 0.3, so 0.1 + 0.2 == 0.3 is true when cast as f32.
    Rust:
    println!("{}", 0.1 as f32 + 0.2 as f32 == 0.3 as f32);
    Even other interpreted languages like Python give you the 'decimal' module as part of the standard library, which lets you handle it like so:
    Python:
    from decimal import Decimal
    print(Decimal('0.1') + Decimal('0.2') == Decimal('0.3'))
    which returns true.
    The Decimal module handles decimal numbers as exactly their mathematical equivalent (up to a certain cutoff, which can be manually extended).

    • @scezar8880
      @scezar8880 Před 3 měsíci

      the rust thing is really weird but surprisingly true
      though I don't think it's comparable to the decimal lib in python
      it's just that JS floats are 64 bit by default, and you're manually casting it to 32 bits which have less precision, or something

    • @guillaumebrunerie
      @guillaumebrunerie Před 3 měsíci +1

      It’s just by accident that with f32 you get 0.1 + 0.2 == 0.3. Try 0.1 + 0.6 == 0.7 for instance and you will get false in Rust while you get true in Javascript.
      Decimal numbers are not comparable at all to floats, for instance 1 / 3 is not a decimal number, which makes them pretty useless for many applications.

    • @thekwoka4707
      @thekwoka4707 Před 2 měsíci

      There isn't really a way to solve them in any language. It just happens to work out in some ways.
      You can just do integer math to avoid it.

  • @davidlightfoot3217
    @davidlightfoot3217 Před 3 měsíci

    When coding in Python, at least, I would use raw strings for regex

  • @AKen_Films
    @AKen_Films Před 3 měsíci +1

    Dude looks like Peewee Herman and the guy who played Polkadot man from The Suicide Squad.

  • @soham9119
    @soham9119 Před 4 měsíci

    I would like to hear your thoughts on Devin AI and it's impact on job market

  • @harshvardhansankpal716
    @harshvardhansankpal716 Před 3 měsíci +1

    plz tell me theses are the stress buster questions which u and ur interviewer will laugh on after him asking abt, promises, event loops and other stuff.

  • @deadlyecho
    @deadlyecho Před 3 měsíci +1

    I got 8/10, the first one got me, I didn't even know that '0' means octal 😂 and what the fuck is string raw 😂😂

  • @jason13gaming
    @jason13gaming Před 3 měsíci +2

    Re-title the video to “10 reasons to avoid JavaScript at all costs”

  • @domesticcadiz
    @domesticcadiz Před 3 měsíci

    What is funny is i only knew the one you got wrong. I got a lot to learn 😂

  • @thekwoka4707
    @thekwoka4707 Před 2 měsíci

    Starts off wacky. Since in strict mode the first one would throw an error, not evaluate to anything. And modules are automatically strict mode.

  • @kazmi401
    @kazmi401 Před 4 měsíci +5

    Delete it Before interviewers come here.

  • @spartanboosts
    @spartanboosts Před 3 měsíci

    Cool vid!

  • @chiragbansal7786
    @chiragbansal7786 Před 4 měsíci +3

    Only got 7/10 right, time to quit being a JS dev and start farming or something

  • @ivangechev4243
    @ivangechev4243 Před 4 měsíci +10

    This is quiz is filled with questions only related to javascript behaviors that are weird and most likely if you know what you do won't ever see.

    • @ConnerArdman
      @ConnerArdman  Před 4 měsíci +10

      Yeah that’s kind of the point haha. And while you’ll never see these things specifically, I actually think knowing them is a decent proxy for having a deep understanding of the language.

  • @ryostyles9904
    @ryostyles9904 Před 4 měsíci +5

    So i failed to answer all the ones which you answered right, but answered the one you answered wrong 😢

    • @ConnerArdman
      @ConnerArdman  Před 4 měsíci +7

      If we combine our powers, we’d be unstoppable…

    • @WeaselOnaStick
      @WeaselOnaStick Před 3 měsíci +1

      ​@@ConnerArdmanOr fail all 100%

  • @herok3447
    @herok3447 Před 3 měsíci +3

    Thank god, we dont send people into space using this language

  • @iamplk
    @iamplk Před 4 měsíci +2

    why he looks like AI character. all time i was analysing his movements lol

    • @ConnerArdman
      @ConnerArdman  Před 4 měsíci +2

      Too much time working for the Zuccbot, so I’m still part lizard robot for now…

    • @iamplk
      @iamplk Před 3 měsíci +1

      @@ConnerArdman are you for real a robot?

  • @bdafeesh
    @bdafeesh Před 3 měsíci

    Jezuz, so much JS ready to ruin your day. An empty array is truthy?? Implicit string-> number conversion...but only sometimes where it's number -> string conversion instead!? Implicit bool -> number conversion?! My mind is melting...

  • @RayBellis
    @RayBellis Před 3 měsíci

    NB: the questions are not always the same.

  • @nathanbourquin6554
    @nathanbourquin6554 Před 3 měsíci

    Leading zero becomes an octal number because… 0 looks like O?

  • @MrHenryG123
    @MrHenryG123 Před 4 měsíci

    Why on earth does typeof return a string instead of the actual type

    • @ConnerArdman
      @ConnerArdman  Před 4 měsíci +2

      Because it has to return a value like any other function, operator, etc. Types aren’t values. For example, you can’t return just the number type. You need a value to describe what type it is, and a string like “number” is a reasonable way to do that.

    • @MrHenryG123
      @MrHenryG123 Před 3 měsíci

      @@ConnerArdmanI suppose that is reasonable in JavaScript since there are not that many actual types (i.e. you can't define your own so you probably don't care about the robustness. Not to say it isn't robust, it just seems a bit unintuitive at first)

    • @RayBellis
      @RayBellis Před 3 měsíci

      @@ConnerArdman you actually can return types e.g. `Number` from a function. There must be some other reason that JS doesn't do that.
      Try e.g. const n = () => Number ; n()(3)

    • @ConnerArdman
      @ConnerArdman  Před 3 měsíci +1

      That is not returning a type. Number is a constructor function for creating Number objects. I guess you could make an argument for returning these wrapper object constructors, but I think that would be _really_ messy.

    • @RayBellis
      @RayBellis Před 3 měsíci

      @@ConnerArdman hmm, true, but constructor functions are _almost_ an analog for types, especially since the ES5 class syntax.

  • @abdelrhmanmohamed4754
    @abdelrhmanmohamed4754 Před 4 měsíci

    hi can you make a video how much javascript is enough before react js , because someine tell me i should can build in big app with js , is that true

    • @DarthVader11912
      @DarthVader11912 Před 4 měsíci

      If you want to learn JavaScript and react do the Odin project it's amazing and very detailed.

    • @ConnerArdman
      @ConnerArdman  Před 4 měsíci +1

      There is no single threshold, it’s pretty subjective. You should be pretty comfortable with JavaScript though imo.

    • @yt-sh
      @yt-sh Před 4 měsíci

      czcams.com/video/m55PTVUrlnA/video.html
      just start building at first, then you'll dive deeper and deeper

  • @suhaib_nisar
    @suhaib_nisar Před 4 měsíci

    ❤ from Kashmir

  • @user-ml5em9eo2e
    @user-ml5em9eo2e Před 3 měsíci +5

    My god JavaScript is a horrible language

  • @AbdurRahim-eu3zr
    @AbdurRahim-eu3zr Před 4 měsíci

    More videos like this

  • @Heheh01737
    @Heheh01737 Před 4 měsíci +1

    Just had a doubt that are these test and things actually useful in the code like when I work with JavaScript I don't use all this stuff if something is there that I don't understand I learn it on the go is it the right approach or like I need to reevaluate?

    • @ConnerArdman
      @ConnerArdman  Před 4 měsíci +6

      If you used something in this video regularly, you would probably be doing something wrong haha. I think understanding how these things work can be a good proxy for understanding of how the language works, but this is just a fun quiz. It's not meant to be the most practical knowledge ever.

    • @RayBellis
      @RayBellis Před 3 měsíci

      @@ConnerArdman yes, this. If you don't explicitly ensure that all of your variables are of the type you expect, or if you use operators on types for which they are not intended so that implicit coercion happens, then you deserve all you get. The coercion rules *are* specified and deterministic, but no-one should be using them.

  • @MyWatermelonz
    @MyWatermelonz Před 3 měsíci +1

    Lol, people actually defending the dumpster fire that is JS

  • @SnazzieTV
    @SnazzieTV Před 3 měsíci +1

    These questions are stupid, no real world scenario would you have these.

  • @kxhu
    @kxhu Před 3 měsíci

    me no no wanna

  • @zFede_Rico
    @zFede_Rico Před 3 měsíci +2

    i learned something today:
    Do NOT use javascript.

  • @MrJester831
    @MrJester831 Před 4 měsíci +1

    This video makes JS look really bad

    • @foo0815
      @foo0815 Před 4 měsíci +4

      Because it is.

  • @matthewchampagne9621
    @matthewchampagne9621 Před 3 měsíci +1

    This language has to be a joke

  • @p1p1sasa
    @p1p1sasa Před 3 měsíci

    I HATE JAVASCRIPT!!!!!

  • @foo0815
    @foo0815 Před 4 měsíci

    Javascript is just the most stupid programming language ever.

  • @Samarichitane
    @Samarichitane Před 3 měsíci

    What a clown language. I hate it.

  • @MasterSamus
    @MasterSamus Před 3 měsíci

    All this proves is that JavaScript is a shitty language made in a weekend. And all standards and tooling for it follow the same philosophy of rushed and esoteric for the dumbest reasons.

  • @jonragnarsson
    @jonragnarsson Před 3 měsíci

    JavaScript? More like JesuScript, beause you will be constantly saying Jesus Fucking Christ, What The Fuck is going on in the language?

  • @myanrueller91
    @myanrueller91 Před 3 měsíci

    “JavaScript default sort converts to strings first.” And this is why people don’t like JavaScript.

    • @RayBellis
      @RayBellis Před 3 měsíci

      Rubbish. Perl's default sort functor is also a string sorter. A sort function has to have _some_ default functor so why should it be a numerical sort instead of a lexical sort?

  • @jvfr-
    @jvfr- Před 3 měsíci

    lol those are useless, stupid ass questions. this ain't never happening in a real world project. I hate when interviewers ask those kind of questions, It just shows that I shouldn't have even bothered to participate in the process

  • @jvfr-
    @jvfr- Před 3 měsíci

    people would k1ll somebody because of a programming language lol as long as javascript keeps paying my bills it can keep returning these weird values

  • @PatrickMageez
    @PatrickMageez Před 4 měsíci +1

    This is why I avoid using JavaScript. It's a very nonsensical language

  • @AgressiveBanana
    @AgressiveBanana Před 3 měsíci +1

    JavaScript sucks

  • @jonsmith7718
    @jonsmith7718 Před 3 měsíci

    i gotHelloTwitter
    world correct ...lol and i didn't see the answers before hand either ...