ExFAANG Engineer Watches ExFAANG Take JavaScript Quiz | Prime Reacts

Поделиться
HTML-код
  • Опубликовано: 7 фев 2025
  • Recorded live on twitch, GET IN
    Reviewed video: • ex-FAANG Developer vs ...
    By: / @connerardman
    / theprimeagen
    Become a backend engineer. Its my favorite site
    boot.dev/?prom...
    This is also the best way to support me is to support yourself becoming a better backend engineer.
    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...

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

  • @theondono
    @theondono 10 месяцев назад +1308

    I love that I have pretty much 0 experience with JS, and yet I can get every single question right by asking myself “what would be the craziest possible result here?”

    • @kiattim2100
      @kiattim2100 10 месяцев назад +111

      Yeah they should've thrown some normal curve ball questions, so people don't automatically default to answer with the craziest possible choices.

    • @mitigamespro8757
      @mitigamespro8757 10 месяцев назад

      Except they did.. there were some normal expected ones there.@@kiattim2100

    • @sophiacristina
      @sophiacristina 9 месяцев назад +3

      Just like in high-school, hahha...

    • @alli0oops
      @alli0oops 7 месяцев назад +3

      they were just overcomplicating them. For most of them I could just look at it and be like yeah, 0 is false is true. duh.

    • @sunnybwaj
      @sunnybwaj 6 месяцев назад +1

      You ain't fooling me

  • @tylerlaprade642
    @tylerlaprade642 10 месяцев назад +206

    “I am currently a FAANG developer at this moment” - this was foreshadowing

    • @martin_labastie
      @martin_labastie 5 месяцев назад +1

      severely underrated comment

    • @GreatTaiwan
      @GreatTaiwan 3 месяца назад

      what happened where does he work now

  • @Dorchares
    @Dorchares 10 месяцев назад +396

    javascript feels like when i try to interpret my dreams

    • @brianviktor8212
      @brianviktor8212 10 месяцев назад +13

      And it works, but in mysterious ways.

    • @kiattim2100
      @kiattim2100 10 месяцев назад +17

      Javascript was a mistake.

    • @complexity5545
      @complexity5545 9 месяцев назад +1

      This joke made me crack a rib.

    • @corvoworldbuilding
      @corvoworldbuilding 8 месяцев назад +1

      Profile picture checks out.

    • @Snbd26th
      @Snbd26th 7 месяцев назад

      😂😂😂

  • @DudeWatIsThis
    @DudeWatIsThis 10 месяцев назад +323

    The interview: "Invalid octal 018 that defaults to decimal minus valid octal 015"
    The job: "Should I try to add this through more polymorphism or slap a Visitor pattern into all these classes?"

    • @fredoverflow
      @fredoverflow 10 месяцев назад +32

      Uncaught SyntaxError: Octal literals are not allowed in strict mode.

    • @TheTigerus
      @TheTigerus 10 месяцев назад

      @@fredoverflow hello this is CORS and fuck your app and especially those octal craps, I don't like them

    • @Blaisem
      @Blaisem 10 месяцев назад +7

      perfect profile pic for this comment btw

    • @cloudPvP
      @cloudPvP 9 месяцев назад

      When you can go Visitor, always go Visitor

    • @zahell
      @zahell 7 месяцев назад

      roll your own rtti

  • @capivaracafeinada
    @capivaracafeinada 10 месяцев назад +93

    For the Raw string question, in Python, we often use raw strings to type regex. They are already complicated enough, and we don't want to make them even more complicated by having to escape all the backslashes

    • @ty.davis3
      @ty.davis3 10 месяцев назад +18

      It's also much nicer in Python because you just have to prepend an 'r' and you're good

    • @qwfp
      @qwfp 10 месяцев назад +15

      And in Python you have to prepend 'f' to get variable formatting inside the string. (which you can combine with 'r' to get that French strings 🥖)

    • @o1-preview
      @o1-preview 10 месяцев назад +3

      *python2 flashbacks*

    • @apollolux
      @apollolux 10 месяцев назад +3

      Sounds like a skill issue. Real programmers escape all the backslashes and charge their employers for the time spent doing it. ;)

    • @dealloc
      @dealloc 9 месяцев назад +1

      Same main reason why String.raw was introduced in JS; to be used to create regex patterns as strings that can be compiled to RegEx objects later that can be processed. Before this you'd have to escape the escapes, e.g. /Hello
      World/ into `Hello\
      \
      World`.

  • @itsteelworks
    @itsteelworks 10 месяцев назад +255

    It is truly amazing how much of JavaScript you miss out on by not doing aggressively stupid things with it

    • @o1-preview
      @o1-preview 10 месяцев назад +10

      100% this

    • @ben_clifford
      @ben_clifford 9 месяцев назад +1

      I just gave this comment its 70th like. Sorry about that.

    • @arthurmoore9488
      @arthurmoore9488 9 месяцев назад +2

      @@RichardRemer The largest problem is the same issue I have with PHP not running in strict mode. Even if I'm coding in TypeScript, at runtime an API could return the wrong type! It's a philosophy decision. JavaScript and PHP are deliberately designed to continue execution with garbage data rather than fail.

    • @miguelito2361
      @miguelito2361 8 месяцев назад

      If your code does not look like
      var myInt = new Array(0b17 % spaghetti*4);
      ... you are not really coding

    • @TheNerdyCanuck
      @TheNerdyCanuck 3 месяца назад

      Yeah I hated every second of this

  • @ConnerArdman
    @ConnerArdman 10 месяцев назад +24

    Can’t tell if I’m being gaslit or if I have been saying NaN wrong all this time…. 😅

    • @Greedsmith
      @Greedsmith 8 месяцев назад +2

      I mean, there are multiple ways of saying it.
      “Nan”, “N A N” or “Not a number”.
      Just like SQL.
      “S Q L” or “Sequel”.

    • @LPFan33
      @LPFan33 4 месяца назад +2

      @@Greedsmith "Squeel"

    • @mareksicinski3726
      @mareksicinski3726 28 дней назад

      say it how u feel

  • @shell_jump
    @shell_jump 10 месяцев назад +262

    I finally understand the rust people.
    Its javascipt devs who got out of a toxic relationship and now they want to date the opposite person.

    • @xXYourShadowDaniXx
      @xXYourShadowDaniXx 10 месяцев назад +58

      The borrow checker might be annoying, but have you ever programmed in Javascript? - Rust devs

    • @hamm8934
      @hamm8934 10 месяцев назад +31

      And after dating their opposite, theyll balance out in the middle, Go.
      Or they take another detour and go elixir for a year

    • @_KondoIsami_
      @_KondoIsami_ 10 месяцев назад +12

      It's more like they have pathological tendencies and can't avoid toxic relationships, they went from idealizing JS to idealizing Rust.

    • @seand7603
      @seand7603 10 месяцев назад +6

      Nah most of them go TS. Once they dip into the crazy they're hooked for life.

    • @SimonBuchanNz
      @SimonBuchanNz 10 месяцев назад +6

      Funnily enough, I really like both JavaScript and Rust.
      They complete each other.

  • @colin_actually
    @colin_actually 10 месяцев назад +266

    In a javascript quiz the answer is always "why"

    • @svenmify
      @svenmify 10 месяцев назад +3

      I find that applies more to languages like rust where everything is “ugh” and “why” and “do I really have to do all this and write macros for something that would be 1 line in c# or js”.
      (Sorry, just learning rust and not having a great time. JavaScript looks pretty nice right now)

    • @gabrielmonpereveutpasqueje9018
      @gabrielmonpereveutpasqueje9018 10 месяцев назад +3

      quiz is the answer. why is the question

    • @testacals
      @testacals 9 месяцев назад

      @@svenmify rust is comparatively low level than c# or js. That's why.

    • @svenmify
      @svenmify 9 месяцев назад +1

      @@testacals oh I know that. But something like Swift is also lower level (arguably a little less than rust), but way easier to code in.
      A lot of the stuff I dislike about rust are design decisions

    • @ToveriJuri
      @ToveriJuri 7 месяцев назад

      @@svenmify
      Looks like Harrison Ford recruited yet another aspiring rust cul... developer.

  • @daniel29263
    @daniel29263 10 месяцев назад +71

    Alternative title: "When you create a language over a weekend"

  • @gilligan87
    @gilligan87 10 месяцев назад +16

    Hey man, just wanted to thank you.
    I'm learning to code and despite working in tech for over a decade, there's a part of me that has always resisted/dreaded coding because in my mind it has always seemed like the epitome of postmodern desk slavery.
    But you make it fun. You're always super hyped and having fun with coding. I'm not really learning that much from you, but listening to you having so much fun with it just makes it seem less soul sucking and has helped me have more positive associations with coding, which has really motivated me to do more learning in my spare time.
    Just a fellow anon or here appreciating your passion. Never change!

    • @cameron7374
      @cameron7374 10 месяцев назад +4

      This is really interesting to me.
      Since in my mind code was always the thing that lets me make the computer do things.
      Like, it's the stuff that video games are made out of and the fact that I know how to do that now would probably make 5 year old me happy. (and also makes me happy now :) )

    • @gilligan87
      @gilligan87 10 месяцев назад

      @@cameron7374 yeah I'm coming to see it more like this now, largely thanks to prime and LLL.
      It's weird - I had his experience with manufacturing first. When I started working with startups and got to see how things are made behind the scenes, actually going to suppliers, operating high tech machinery, working with vacuum chambers and plasma and lasers and CNC machines etc, it gave me a massive appreciation for the whole process. I was instantly hooked.
      But software always seemed like the drab side of things. Working with hardware was interesting and seemed like it had more room for creativity; coding just seemed laborious, just stitching together the hardware with boring 1s and 0s.
      It took actually taking a coding class and building some CLI apps in C to give me that same feeling about code. I see now how much of a rush it can be to problem solve with code, how intellectually stimulating it can be, and above all else how rewarding it is to build something that really works.
      I'm taking a break from studying at the moment because my daughter was just born a few months ago, but watching prime and keeping up my practice on sololearn has me excited to get back to my comp eng classes.

  • @KyleHarrisonRedacted
    @KyleHarrisonRedacted 10 месяцев назад +15

    I am pretty sure the title changed from “FAANG engineer reacts to ExFAANG engineer” right after the announcement on the main channel lol

  • @mattmmilli8287
    @mattmmilli8287 10 месяцев назад +65

    lol he updated the title cause he left Netflix 😂

  • @ruanpingshan
    @ruanpingshan 10 месяцев назад +10

    I don't know about Javascript, but in other languages, the main use cases I've seen for raw strings are:
    1. Writing regexes without having to escape \
    2. Pasting the contents of a multi-line text file into a string literal.
    3. Writing GLSL shaders or other dynamically compiled code from a different language, so they don't need to be shipped as separate files.
    4. Writing multi-line strings for whatever other reason.

  • @spicybaguette7706
    @spicybaguette7706 10 месяцев назад +44

    I love this one even more:
    String('123') instanceof String

    • @daniel29263
      @daniel29263 10 месяцев назад +11

      JS is truly a language of all time

    • @itsteelworks
      @itsteelworks 10 месяцев назад +9

      Pure rage.... But also, you construct new String objects with `new String()` and the fact that it doesn't crash when you do that without new is the part that's actually weird and wrong

    • @SimonBuchanNz
      @SimonBuchanNz 10 месяцев назад

      ​@@itsteelworksof course. String is a function that converts things to primitive strings, and new String is a constructor that creates String instances.
      You can even do this with your own types, just check new.target in your functions or constructors and return a value to use instead! Just remember that you can't return a primitive if the caller used new, or it will ignore the value and return the this value it created for you.
      It's so simple and nice! 🫠

    • @yoz0__
      @yoz0__ 10 месяцев назад +3

      But Object('123') instanceof String is true
      same for new Object()
      Javascript, I love it

    • @adambalint5121
      @adambalint5121 10 месяцев назад +4

      @@RichardRemer But why would a cast using String result in a string, I would not call that "consistent" at all. The sane expectation still would be that it casts to String, not string.

  • @wojciechosinski5927
    @wojciechosinski5927 10 месяцев назад +4

    I love that after 20min of bamboozling there was a phrase in an explanation to one of the questions: “if you do this instead you’d get a result you would have expected from the beginning”. You can’t expect anything after that

  • @DominoPivot
    @DominoPivot Месяц назад +1

    Q1. Octal number literals without prefixes are a syntax error in strict mode, and any code written over the last 15 years has no reason to not be written for strict mode.
    Q4. I would never rely on the == algorithm which is recursively defined with 15 branches, a real nightmare. Still, in this case, given two primitives where one is a boolean, it casts the boolean to a number. Then given a number and a string, it casts the string to a number. 0 == 0 is true.
    The explanation given was wrong because it suggests that false is first coerced to "0", but it isn't. In fact, at 14:00 a correct explanation is given for another question. The == algorithm never converts other primitives to strings. It does convert objects to primitives before comparing them to primitives, which looks for a `Symbol.toPrimitive`, `valueOf` or `toString` method on the object in that order, and otherwise throws. Most objects inherit from Object.prototype which has a default implementation of `toString`, which is why you might think == falls back to strings, but the blame lies on the ToPrimitive algorithm for objects only.
    But wait, I've seen people write `if (value == null)` to check for both null and undefined, would that throw if given an object that doesn't inherit from Object.prototype? No, because the == operator is explicitly defined to perform comparison to null or undefined early, so it won't even attempt to cast an Object when comparing to either of them. Yes, == is horrible, if JS didn't have to stay backwards compatible it would have been replaced instead of === being added.
    Q6. As you explained, this creates an array with empty items, or holes. The explanation provided on the quizz actually gets that right... only to then represent that as [1, 2, 3, undefined, undefined, undefined, 9] which is not correct. The proper array literal representation would be [1, 2, 3, , , , 9] but as you showed, dev tools are nice enough to tell you the number of empty items instead.
    What's the difference between a hole and a property? A hole doesn't block inherited properties. So Object.setPrototypeOf([1, 2, 3, , , , 9], [,,,4,5,6]).map(x => x) produces [1, 2, 3, 4, 5, 6, 9]. And because of this, accessing elements on an array with holes is incredibly slow.
    Q7. The explanation here is correct, but what ThePrimeTime says isn't. We say a value is truthy if the ToBoolean algorithm would return true, not when it is == true. Arrays are objects, objects are truthy, so even empty arrays are truthy. The reason false == [ ] is true is once again because the == operator uses the ToPrimitive algorithm which, on objects can end up calling toString.
    false == [ ]
    false == ToPrimitive([ ])
    false == [ ].toString()
    false == ""
    ToNumber(false) == ""
    0 == ""
    0 == ToNumber("")
    0 == 0
    true
    Again, this is never a problem in the real world because you do not use == in the real world.
    Q9. Including the quotation marks is inconsistent with previous questions and confusing. String.raw`HelloTwitter
    world` is equivalent to the string literal "HelloTwitter\
    world" but your console would likely log HelloTwitter
    world without quotes and without escaping the backslash.
    The point of String.raw is for when you want to write some code inside a string, and don't want to have to escape the backslash twice if the language of the code you are writing also uses them. It's similar to the r prefix in Python.
    Q10. Not an issue with the question, but I did use new String once to experiment with WeakMap, whose keys have to be objects. I've yet to find a convincing use case for WeakMap though.

  • @genxer1824
    @genxer1824 10 месяцев назад +19

    It cares more about debugging and foundational understanding than pure DS&A.
    I have to admit, against my better judgment, I like this quiz.

  • @JSmith73
    @JSmith73 9 месяцев назад +19

    If you grew up with a typewriter (before eg graduating to a Vic20), the newline+return sequence makes perfect sense as they were two very distinct actions. 😂
    Greatly enjoyed this episode.

    • @micahburnside2281
      @micahburnside2281 7 месяцев назад +1

      Gotta send the printer back to the left side of the page after new line.

    • @multivariateperspective5137
      @multivariateperspective5137 6 месяцев назад

      Super fun yea

    • @tttm99
      @tttm99 6 месяцев назад

      I think the odd keyboard still has an enter/return key with an arrow on it that goes downwards and then points back to the left. The clue to 13 and 10 being two instructions hence two characters is even there.👍 But you're right. If you've used a typewriter before you can't fail to differentiate line feed from carriage return.
      I wonder... Should the 'return' key be called the line feed carriage return key for completeness? 🥴😂

  • @toifel
    @toifel 10 месяцев назад +25

    I'll have to lay down after this

  • @StinkyCatFarts
    @StinkyCatFarts 10 месяцев назад +11

    I love that you would never actually run into these problems if you code properly

  • @killermonkey1392
    @killermonkey1392 10 месяцев назад +17

    JS's type coercion is a crime against humanity. Most of these questions should just TypeError…

  • @arbleizbzh7672
    @arbleizbzh7672 8 месяцев назад +1

    "If it's true, I'm gonna commit sudoku". Wow that's some high level of devotion to the cause man! :D

  • @user-wf7uf2jp8x
    @user-wf7uf2jp8x 10 месяцев назад +4

    HE CHANGED THE TITLE OMG

  • @meatcow417
    @meatcow417 10 месяцев назад +3

    lmao, that was a short-lived title.

  • @Kmps2341af
    @Kmps2341af 3 месяца назад

    this is so good.. Please do more of this.. Your channel is crazy awesome

  • @JSHyCS
    @JSHyCS 10 месяцев назад +1

    now it's an ex-faang developer watches ex-faang developer take javascript quiz

  • @JLarky
    @JLarky 10 месяцев назад +3

    I like how Prime says "ha ha, look at chat in disbelief" and continues to be in disbelief for the next question himself 😔

  • @EpicRag
    @EpicRag 10 месяцев назад +32

    Hearing expert JavaScript developers talk about its type system is a prime example of Stockholm Syndrome.

    • @Ba-gb4br
      @Ba-gb4br 10 месяцев назад +8

      """"" type system """""

  • @alexm9104
    @alexm9104 10 месяцев назад +3

    It's kinda entertaining to see chat slowly become completely hysterical, ngl.

  • @MrOboema
    @MrOboema 10 месяцев назад +4

    @14:15
    theprimeagen: *concentrating very hard to follow the exact logic behind Javascript's blackmagik type conversion*
    chat: uh-huh-huhhuh...he said "bang array"
    😂

  • @smddev
    @smddev 10 месяцев назад +1

    In the future fang engineers will be the people designing cyborg vampire teeth

  • @markosth09
    @markosth09 10 месяцев назад +5

    From the ECMAScript spec:
    7.2.14 IsLooselyEqual ( x, y )
    The abstract operation IsLooselyEqual takes arguments x (an ECMAScript language value) and y (an ECMAScript language value) and returns either a normal completion containing a Boolean or a throw completion. It provides the semantics for the == operator. It performs the following steps when called:
    1. If Type(x) is Type(y), then
    a. Return IsStrictlyEqual(x, y).
    2. If x is null and y is undefined, return true.
    3. If x is undefined and y is null, return true.
    4. NOTE: This step is replaced in section B.3.6.2.
    5. If x is a Number and y is a String, return ! IsLooselyEqual(x, ! ToNumber(y)).
    6. If x is a String and y is a Number, return ! IsLooselyEqual(! ToNumber(x), y).
    7. If x is a BigInt and y is a String, then
    a. Let n be StringToBigInt(y).
    b. If n is undefined, return false.
    c. Return ! IsLooselyEqual(x, n).
    8. If x is a String and y is a BigInt, return ! IsLooselyEqual(y, x).
    9. If x is a Boolean, return ! IsLooselyEqual(! ToNumber(x), y).
    10. If y is a Boolean, return ! IsLooselyEqual(x, ! ToNumber(y)).
    11. If x is either a String, a Number, a BigInt, or a Symbol and y is an Object, return ! IsLooselyEqual(x, ? ToPrimitive(y)).
    12. If x is an Object and y is either a String, a Number, a BigInt, or a Symbol, return ! IsLooselyEqual(? ToPrimitive(x), y).
    13. If x is a BigInt and y is a Number, or if x is a Number and y is a BigInt, then
    a. If x is not finite or y is not finite, return false.
    b. If ℝ(x) = ℝ(y), return true; otherwise return false.
    14. Return false.
    ℝ(x) stands for the mathematical value of x, which normalizes +0 and -0 into 0 and is not defined for non finite values.

    • @cameron7374
      @cameron7374 10 месяцев назад +1

      4. NOTE: This step is replaced in section B.3.6.2.
      EXCUSE ME?

  • @jfftck
    @jfftck 10 месяцев назад +11

    The best part is JavaScript added “use strict” and none of these are addressed by this flag, you would think that octals would have required the 0o syntax. Maybe they should add a “really use strict” flag!?

    • @snakefinn
      @snakefinn 10 месяцев назад +5

      "For real this time"

    • @Sandromatic
      @Sandromatic 10 месяцев назад +1

      May I introduce you to Perl's pragmas :P

    • @fredoverflow
      @fredoverflow 10 месяцев назад +1

      Both 015 and 018 do throw errors in "strict mode" though?

    • @jfftck
      @jfftck 10 месяцев назад +1

      @@fredoverflow You’re right, but how many people use “use strict” because of the limited improvements that come with it? I tried using “use strict” in REPL mode (both console and Node) and that doesn’t work, I should have written it in a file to test.
      It should have made coercion apply to only one side of the comparison and only be applied once, arrays should have required to be the same type for all elements, and add boxing of values. With the number of people who create videos like this, it shows that removing these problematic behaviors would lead to less errors for developers.

    • @jfftck
      @jfftck 10 месяцев назад +1

      @@RichardRemer My problem with “use strict” is that it doesn’t apply enough changes to fix these tricky questions in the quiz. One of the biggest issues is inconsistency with type coercion, when sorting it always casts to string but then in comparisons it doesn’t and it can cast more than once. There needs to be a stricter set of rules that makes type coercion only work for comparisons and arrays are only allowed one type, this would fix the majority of the problems and have types that are predictable.

  • @ratman505
    @ratman505 10 месяцев назад +4

    ~26:40 - The rule is not completely consistent, at least not at first glance. Java uses a String pool for optimization and Strings that are referenced multiple times are therefore the same instance and `==` returns true. However that is not the case for all methods that can create new Strings. I do not know which methods create separate instances and which do not

    • @Rongmario
      @Rongmario 10 месяцев назад +2

      It also differs based on JVM implementations, such as OpenJ9 having stricter string interning. You should definitely always use `.equals` when comparing strings, it short-circuit checks refs in the equals implementation anyway!

  • @rahil_rehan
    @rahil_rehan 10 месяцев назад +1

    I'm going thru like a worst phase of my life! Both professionally ans personally.
    Watching your videos makes my day. Thanks Prime.

  • @KazmirRunik
    @KazmirRunik 8 месяцев назад

    24:26 YES, I have used the String constructor for an actual functioning purpose.
    When you use the strings as map keys and two of those keys might be identical strings BUT you want to process the identical strings differently (for instance, based on their position or based on a user-selected process), then if you map the strings to their processing outputs, using String constructors lets you map two identical strings to two different processing outputs. If you didn't use the constructor, the second string processed would overwrite the first when you map that process output to the string, which you don't want if your goal is to process the two strings differently.
    The catch is that you have to handle all keys symbolically or retrieve them with a keys() function call if you want them, which is fine since you're probably going to be processing dynamic instead of literal strings anyway.
    Now, here's a bonus JavaScript quirk in the form of a quiz problem:
    let a = new String('hey');
    let b = new String('hey');
    let c = 'hey';
    console.log(a == c); // guess the output of this first, then try it
    console.log(b == c); // guess the output of this second, then try it
    console.log(a == b); // guess the output of this third, then try it

  • @RealRatchet
    @RealRatchet 10 месяцев назад +5

    I actually got wrecked by sort implicitly casting to string once. Worst part was that I wasn't actually the one writing the frontend I wrote the backend that consumed the sorted array.

    • @xelspeth
      @xelspeth 10 месяцев назад +1

      tbf if you expect a sorted array and the client does not send a sorted array, that's an FE issue not a BE issue.
      But also there probably shouldn't be the need for a sorted array and the BE should sort the array itself regardless

    • @IndigoTeddy
      @IndigoTeddy 10 месяцев назад +1

      ​@@xelspeththis. Everything should be done in the backend except fetch requests, storing cookies/temporary identifier variables, and DOM manip unless you have a specific edge case (such as using WASM or somehow not having a backend for your calculator website). If your company doesn't have control over the full tech stack though, then you're gonna have to contact the frontend devs to redesign your protocols for what data to send over the wire.

  • @asdfasdfasdf1218
    @asdfasdfasdf1218 10 месяцев назад +2

    Besides regex, raw strings can also be for windows paths.

  • @ifscho
    @ifscho 10 месяцев назад +2

    I love the title change. 😄

  • @BachPhotography
    @BachPhotography 10 месяцев назад +2

    Very interesting video, I got almost all of them wrong, except for the String.raw
    I've had to use String.raw before when parsing JSON where some of the object attributes are also JSON (doubly stringified!), to avoid the backslashes in the double stringified json being used as escape characters

  • @sannfdev
    @sannfdev 9 месяцев назад +2

    This is why I love the ThePrimagen: he turned an 11 minutes video into a 30 minute reaction. He's not just sitting there in the corner; he actually adds to the content. Love it.

  • @DrewIsFail
    @DrewIsFail 7 месяцев назад +1

    Mdn doc on '==' say It works ona case by case basis so:
    > Number to String: convert the string to a number...
    So the explanation by the quiz was correct.

  • @mAximUm123451
    @mAximUm123451 9 месяцев назад +1

    2:10 I just learned that NaN is "Not a Number"... after all these years

  • @atiedebee1020
    @atiedebee1020 10 месяцев назад +4

    Javascript makes C's undefined behaviour look sane

  • @abtix
    @abtix 10 месяцев назад +2

    21:50 In the case that you're saying you don't know how to use it because you don't understand it, since it's raw but not really because it still evaluates the variables, the best way I can explain it is that that's only due to the backticks (``) surrounding the text, which I assume tells Javascript to evaluate the variables, and String.raw doesn't really interfere with this process. If it had the single or double quotes, it would have included the ${varOne} and ${varTwo}.
    And in the other case where you are wondering why you would need to use String.raw at all, I have found myself needing to use this at times when I was trying to either be able to log out the raw thing in LLM responses, since I was trying to figure out if it was giving
    or
    alone. I bet there's some dynamic finetuning data generation use cases too.

  • @telephonedude
    @telephonedude 10 месяцев назад +5

    I am unreasonably perturbed by the fact that `[]` can be coerced into both `true` and `0` depending on the type chosen.

  • @slobrat3556
    @slobrat3556 7 месяцев назад

    It felt good to get one of those questions right, i was air humping the raw dog question

  • @Maskrade
    @Maskrade 10 месяцев назад +3

    now it will have to be an ExFAANG

  • @vorant94
    @vorant94 10 месяцев назад +6

    Need to update the title as there are two ex-FAANG-ers here now))

  • @n4bb12
    @n4bb12 7 месяцев назад

    21:55 logging, debugging... when you want to see what's in the string. If whitespace gets printed regularly, it's difficult to see which type of whitespace it is.

  • @ytsks
    @ytsks 10 месяцев назад +6

    Not calling it String.rawdog is a mistake and you can't change my mind.

  • @sfulibarri
    @sfulibarri 10 месяцев назад +2

    Principle of most surprise lmao. Actually insane that js became so dominant.

  • @jefferymuter4659
    @jefferymuter4659 9 месяцев назад

    "I am currently a FAANG developer... as of this moment"
    Bro was telling us the writing on the wall.

  • @sacredgeometry
    @sacredgeometry 10 месяцев назад +3

    JS is responsible for a whole generation of programmers thinking this sort of shit is acceptable and you can see it in their code.

  • @danielbrockman7402
    @danielbrockman7402 10 месяцев назад +2

    I wish you would put the links to the materials you are reacting to in the description, that seems respectful but also helpful, this has bothered me several times is when I wanted to try to go look at it myself. Love the content though. I wish I had the video that I made you react to once which was dave portnoy the barstools sports founder ranting about bitcoin, comparing it to "that emoji game" and so on, it was taken down for some reason. by the way, you are wrong about the conversion, 1 == "1" converts those to numbers, hence e.g. 1 == "+1.0e0", edit: lol sorry this was explained just a few minutes later, I think the explanation is that it's kind of like a special case that strings when compared to numbers is done that way, and then false is simply always converted into zero, but yeah I can't explain it either. it doesn't really make any fucking sense whatsoever

    • @ThePrimeTimeagen
      @ThePrimeTimeagen  8 месяцев назад

      i do almost always have it... if its not in there, then its a mistake more than anything else. total accident if there is no link

  • @chri-k
    @chri-k 7 месяцев назад

    "5 empty items" becomes even more cursed because in some cases "empty items" from an array can end up in non-array objects with string keys, and then there is no way to remove them

  • @andythedishwasher1117
    @andythedishwasher1117 10 месяцев назад +3

    Just curious, does anyone here actually write conditions that depend on Javascript's type coercion system? Personally I avoid it like the plague and just make the most explicit conditions possible whenever I'm nose plugging my way through a JS build.

    • @KennyWlr
      @KennyWlr 4 месяца назад

      Not anyone that has ever loved anyone in their life, I'm sure.

  • @xXzennerXx
    @xXzennerXx 8 месяцев назад

    26:25 BTW, JAVA handles strings with a stringPool. Each unique string has one reference in memory, so comparing the reference or the actual value is the same. Unless you compare “a” == new String(“a”), then the reference is different.
    But “a” == “a” is true

  • @tjhooperofficial
    @tjhooperofficial 9 месяцев назад

    javascript is the definition of "just because you can doesn't mean you should"

  • @danielmellado5942
    @danielmellado5942 10 месяцев назад +1

    In the question 4, 0 == '0', '0' is converted to a number.
    The specs:
    Abstract Equality Comparison (==)
    The comparison `x == y,` where x and y are values, produces true or false. Such a comparison is performed as follows:
    1. If `Type(x)` is the same as `Type(y)` then
    1. 1. Return the result of performing Strict Equality comparison x === y.
    2. If x is null and y is undefined, return true.
    3. If x is undefined and y is null, return true.
    4. If `Type(x)` is Number and `Type(y)` is String, return the result of comparison `x == ToNumber(y)`
    5. If `Type(x)` is String and `Type(y)` is Number, return the result of comparison `ToNumber(x) == y`
    6. If `Type(x)` is Boolean, return the result of the comparison `ToNumber(x) == y`
    7. If `Type(y)` is Boolean, return the result of the comparison `x == ToNumber(y)`
    8. If `Type(x)` is either String, Number or Symbol and `Type(y)` is Object, return the result of the comparison `x == ToPrimitive(y)`.
    9. If `Type(x)` is Object and `Type(y)` is either String, Number or Symbol, return the result of the comparison `ToPrimitive(x) == y`.
    10. Return false.

  • @GuRuGeorge03
    @GuRuGeorge03 10 месяцев назад +1

    we had something similar as an exam in school. the results were literally that 25% of answers were correct. Which means the results of the entire class were the same that you would expect if everybody just answered randomly.

  • @mxruben81
    @mxruben81 10 месяцев назад +2

    "I am currently a FAANG developer at this moment"

  • @rosco3
    @rosco3 4 месяца назад

    17:20 NaN2 would also make sense, number + string = 'NaN', 'NaN' + '2' = 'NaN2'
    But this is one of the few where JS actually makes sense as it treats everything equally

  • @benjaminfortune2707
    @benjaminfortune2707 10 месяцев назад +1

    At 6:50 ish -- As far as I can find, even though it's counter-intuitive, I believe it actually tries to convert the string argument to a number to do the comparison. If you try 5 == '5.00000' it returns true. If it was as simple as the number argument being converted into a string, these would not be loosely equal. Instead '5.00000' becomes 5
    *Edit* : Should've watched further, didn't think he'd come back to it. Prime talks about it again around the 9 minute mark

  • @Gameboygenius
    @Gameboygenius 8 месяцев назад +1

    8:42 It would've been fun if the question was baity and said. 0.2+0.3==0.5. _Although_ floating point can have inaccuracies, that's an example that works out.

  • @DeadOce4n
    @DeadOce4n 9 месяцев назад

    String.raw can be used to get syntax highlighting for the code inside a string, for example, make a function named "yaml" and just return String.raw from it, call the function somewhere, write some yaml inside the backticks and you get yaml syntax highlighting, at least if you use neovim with treesitter.

  • @kaylee42900
    @kaylee42900 9 дней назад

    The fun one with question 8 that I always catch in code reviews is someone wanting to shorthand a long hand for loop on an array as `for (const i in [1,2,3]) { }` and then for some reason in the code they have to do index manipulation and have no idea why shit isn't working, and it's because the keys going into i are strings and it's concatenating rather than adding.

  • @JustinBowsher
    @JustinBowsher 10 месяцев назад

    every time I hit pause because I thought the in-video pause was on my end, I get back to work.

  • @davea136
    @davea136 8 месяцев назад

    I cannot wait for the Javascript Apocalypse, when Raytheon starts programming nuclear weapons using Node.
    Imagine explaining that to your mutant descendants.

  • @ThatBidsh
    @ThatBidsh 10 месяцев назад +4

    Non-FAANG Engineer Watches FAANG Engineer watching ExFAANG Engineer take JavaScript Quiz

  • @mattias3668
    @mattias3668 10 месяцев назад +1

    Apropos \f (also known as ^L or "form feed"): fun fact, GNU source code is partitioned with form feeds. I haven't see anyone else do that, but it's extremely common in GNU projects.

  • @Akz666
    @Akz666 9 месяцев назад

    God! This is the best video I watch since the beginning of 2024

  • @bradleyjohnson2234
    @bradleyjohnson2234 5 месяцев назад

    I get the vibe that he prewatched (or took this quiz already). Especially since he used the word “quirk” like in the explanation

  • @dewaldesterhuysen712
    @dewaldesterhuysen712 2 месяца назад

    When us electrical engineers work with Modbus RTU and other similar serial interfaces it is nice to make use of Node.js to script some code and work through a COM port. In that case the raw works nice

  • @lukemarshall1892
    @lukemarshall1892 10 месяцев назад +2

    'A very confusing conversion system' is what you tell someone just starting to learn js to give them a heads up without spoiling how atrocious everything is.

  • @seanfuller3095
    @seanfuller3095 10 месяцев назад +2

    Windows users know all about raw dogging strings C:\\señor

  • @MessioticRambles
    @MessioticRambles 10 месяцев назад +3

    I understood most of these, and I can accept most of the ones I got wrong, but the fact that string literals are not instances of strings despite their prototype being string makes me incredibly angry.

  • @MichelBarakat-yc5rj
    @MichelBarakat-yc5rj 10 месяцев назад

    you'd use the constructor String in a case where you have a defined array of objects holding type/value pairs (i.e. a configuration map) and you want to map over it in your runtime and create the variables.
    here's a one liner: `const data=[{t:String,v:'my string'},{t:Number,v:12}];const instances = data.map(({t, v}) => new t(v));`

  • @timturner7609
    @timturner7609 5 месяцев назад

    The floating point one got me because its obviously false in the general case, but there are numbers that reproduce perfectly in floating point so I assumed this was one of the special cases where the stars aligned and the equality held

  • @lunafoxfire
    @lunafoxfire 9 месяцев назад

    omg the fact that I knew all of these even without multiple choice just shows how little hope is left for me in my javascript-rotted brain, lol

  • @Tony-dp1rl
    @Tony-dp1rl 10 месяцев назад +1

    "new Array" in JS can take a long walk off a short pier

  • @pepkin88
    @pepkin88 10 месяцев назад +1

    7:12 here's a way how to test it:
    false == '00' // -> true
    0 == '00' // -> true
    String(0) == '00' // false
    Edit: Aah, he came back to it at 9:10 with the same test as mine 😅

  • @KyleHarrisonRedacted
    @KyleHarrisonRedacted 10 месяцев назад +1

    9:04 I incorrectly guessed it would be true, just because of the loose equivalence operator instead of a strict one. In my head I figured js would go the extra mile and either round to the same floating point placement or just chop off. But I was wrong lol

  • @danielmichel7000
    @danielmichel7000 10 месяцев назад +1

    3:10 the exact same question was in my midterm a couple of days ago and my smartass for some reason thought that typeof would return a sort of Wrapper class so like actually Number not a string (Java reference)...but that turned out incorrect obviously...

  • @RodnDjokYTB
    @RodnDjokYTB 7 месяцев назад

    I don't know who wants to know this info, but if you do
    arr.map(_ => 99) while the arr = new Array(5) --> means empty array of five.
    You can use fill before the map to turn all items to undefined then map through it.
    arr.fill().map(_ => 99) will work.

  • @Shananiganeer
    @Shananiganeer 10 месяцев назад +1

    Java will not duplicate strings in the heap when created with double quotes, so "foo" == "foo" will return true even though it is technically comparing references instead of values. You have to explicitly create additional objects with new String() to break the equality.

  • @learningDeepL
    @learningDeepL 6 месяцев назад

    Why is there ever a moment when we would need loose comparison which can not be done by other more standard ways (seriously asking) ?

  • @insert9124
    @insert9124 10 месяцев назад +1

    The raw string stuff is used when using regex in a language using strings. Everything needs to be backslashed to count in regex, so it need to stay and not "dissapear" as it would in a real string. I did it in python tho so I dont know about javascript, but I assume its the same

  • @NicolasPimprenelle
    @NicolasPimprenelle 10 месяцев назад +2

    If JS was not trying so hard to not throw, it could have been so much better

  • @willsawyerrrr
    @willsawyerrrr 10 месяцев назад +5

    Updated title: “ExFAANG Engineer Watches ExFAANG Take JavaScript Quiz”

  • @itsteelworks
    @itsteelworks 10 месяцев назад +2

    The only reason to use a string constructor is if you've monkeypatched or extended String with additional methods, which you shouldnt do 99% of the time

  • @Mehuge
    @Mehuge 8 месяцев назад

    One use case for String constructor is if you want to store other properties against the string (eg isTranslated)
    let s = "hello";
    s.isTranslated = true
    console.log(s, s.isTranslated)
    s = new String("hello")
    s.isTranslated = true
    console.log(s, s.isTranslated)

  • @jacksonbourne
    @jacksonbourne 10 месяцев назад +1

    at 12:30 there are a few other ways to create empty items. one that comes to mind is [,,,,,,,,,]

  • @MateuszAdamowski-k8b
    @MateuszAdamowski-k8b 9 месяцев назад

    7:10 "I don't know how to test it"
    Well, you can compare: false == ' 0'; // added leading space
    This will still be TRUE, and that's because both values are converted to Number. If they were converted and compared as strings, '0' wouldn't be equal to ' 0'

  • @xRIGGSx1992
    @xRIGGSx1992 10 месяцев назад +1

    so the only time I've used a raw string was to identify different dating formats or directories with regex. but that was in python, idk if it would have the same application in JS

  • @jonathanjacobson7012
    @jonathanjacobson7012 10 месяцев назад +2

    I suppose that JS victims may use raw strings to genererate dynamic code that includes a call that prints out a new line, for instance.

  • @dipereira0123
    @dipereira0123 10 месяцев назад +1

    Being real, if you are in a situation where you need to consider those situations, your code is already f*ucked from at least 2 sprints ago 😂

  • @jacovinus
    @jacovinus 10 месяцев назад +1

    the meme is becoming real:
    reacting the reaction of the one who reacts 😂

  • @kaltwarraith5172
    @kaltwarraith5172 10 месяцев назад +1

    i use js for all kinds of things, including scripting serial ports.
    And i've used the string constructor to ensure proper type conversion in mozilla rhino