Let’s play… Does your code suck? JavaScript Variables Edition

แชร์
ฝัง
  • เผยแพร่เมื่อ 2 ต.ค. 2024

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

  • @wlockuz4467
    @wlockuz4467 7 หลายเดือนก่อน +4264

    You had me at "does your code suck".
    Yes it does.

    • @mesihburgaz8637
      @mesihburgaz8637 7 หลายเดือนก่อน +3

      if you don't know than say it so i can skip you

    • @LuisSierra42
      @LuisSierra42 7 หลายเดือนก่อน +25

      This is the sign of true maturity in software engineering

    • @orterves
      @orterves 7 หลายเดือนก่อน +11

      I gave it a 50/50 till he followed up with JavaScript. Then 100% yes.

    • @justarandomguy6794
      @justarandomguy6794 7 หลายเดือนก่อน +3

      But if you know it sucks then you are better than half of the coders

    • @JeremyAndersonBoise
      @JeremyAndersonBoise 7 หลายเดือนก่อน +5

      Hired.

  • @TehKarmalizer
    @TehKarmalizer 7 หลายเดือนก่อน +3503

    I mostly watch JS videos like this to continue validating why I don’t do web development.

    • @spunzel851
      @spunzel851 7 หลายเดือนก่อน +51

      Then what do you do ?

    • @TehKarmalizer
      @TehKarmalizer 7 หลายเดือนก่อน

      @@spunzel851 internal desktop and CLI tools development, mostly.

    • @migvelv
      @migvelv 7 หลายเดือนก่อน +13

      Same 😂

    • @hikari1690
      @hikari1690 7 หลายเดือนก่อน +110

      But web dev is fun. Though I can't seem to get hired

    • @adam422
      @adam422 7 หลายเดือนก่อน +21

      ​@@hikari1690where are you located?

  • @evanbelcher
    @evanbelcher 7 หลายเดือนก่อน +101

    One of the most important lessons I learned early in my career as a SWE was that exceptions are good. The way they were taught in college, I felt like my job was to make sure nothing ever threw an exception and halted so I ended up with try/catches and log messages everywhere. No: if something goes wrong, you want to throw a good exception and let it break

    • @skyhappy
      @skyhappy 7 หลายเดือนก่อน +1

      When do you decide to not let it break?
      Also do you think that the software education you got in college was poorly taught?
      And did the professors usually have no industry experience?

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

      ​@@skyhappyyou don't let the code break when there's scenarios in which you know it's gonna break so you want to control what happens after the errors come knocking. That's why it's called error handling, blindly catching any and all errors is just a debug nightmare

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

      If you're going into development you'll eventually deal with some application that has a server, and many clients.
      In this scenario you'll have to make everybody talk to eachother, and it's not about if, it's about when a connection error will happen.
      At that point based on the reason of the error happening you might want to have the code try again, notify the user and ask them to check their connection, or kindly tell them that your app is facing some challenge and they should come back at another time

  • @tomasmartinez6726
    @tomasmartinez6726 7 หลายเดือนก่อน +897

    I've avoided using var without knowing what it does, but this really helped me understand, thanks!

    • @CottidaeSEA
      @CottidaeSEA 7 หลายเดือนก่อน +63

      This is not the only reason why it's awful. It also has some real awful scoping issues.

    • @michawhite7613
      @michawhite7613 7 หลายเดือนก่อน +12

      ​@@CottidaeSEA I think the scoping issue is what the video was talking about

    • @CottidaeSEA
      @CottidaeSEA 7 หลายเดือนก่อน

      @@michawhite7613 It was only about one of the scoping issues.

    • @j1000a
      @j1000a 7 หลายเดือนก่อน +44

      Use const until you absolutely can't.

    • @CottidaeSEA
      @CottidaeSEA 7 หลายเดือนก่อน +3

      @@michawhite7613 Unsure if I just can't see my reply, but basically, the video doesn't go into all of the scoping issues.

  • @mylesbuckley9675
    @mylesbuckley9675 7 หลายเดือนก่อน +303

    Gotta love getting a runtime error for something which can be statically checked.

    • @arnerademacker
      @arnerademacker 7 หลายเดือนก่อน +17

      That's just interpreted languages though?

    • @Templarfreak
      @Templarfreak 7 หลายเดือนก่อน +16

      @@arnerademacker yeah, it's an unfortunate but necessary evil in order to have all the other niceties that runtime interpreted languages have.

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

      @@Templarfreak What kind of niceties do you have in mind? Most of the ones I can think of aren't necessarily tied to interpreted languages, but I'm very possibly forgetting some.

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

      @@arobie92 nothing is tied explicitly to any particular interpreted language, no, but that's because any language can be runtime interpreted if you are ballsy and brave enough. at which point, any language can have the benefits of doing so. you get advantages like VERY fast feedback, possibly even basically instant if you can reload the code without needing to reload an entire program.

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

      @@TemplarfreakAh so the primary benefit you're getting at is a managed runtime? I'll definitely agree that hot reloading of modules, while technically doable in compiled code, is significantly easier in managed languages.

  • @stevenclark2188
    @stevenclark2188 7 หลายเดือนก่อน +306

    As a C/C++ guy that's a big "Holy shit people live like this?!" thing.

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

      Tbf, I could say the same about declaring the var typeOf on init. Or having to allocate memory. You and I live on strange worlds, but the other is far stranger.

    • @RealNaisuCinema
      @RealNaisuCinema 4 หลายเดือนก่อน +3

      No, we just don’t use var lol. I’d much rather this than C/C++ 🤢

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

      @@12Fakeaccount you don't need to allocate memory always
      its when you want more control over it that you do
      C/C++ really allow you to access/fu*k up, lower levels of the system
      you can divide by 0 and it continues the program for ever (Alhtough compilers and windows can now catch it)
      both have their uses
      JS for web
      C for Win native applications etc

    • @aleixroca1988
      @aleixroca1988 2 หลายเดือนก่อน +32

      ​@@RealNaisuCinema C/C++ makes you a powerful wizard though

    • @cyber3371
      @cyber3371 2 หลายเดือนก่อน +1

      Fr

  • @echoarts3366
    @echoarts3366 7 หลายเดือนก่อน +472

    My personal go-to: use "const" for everything unless you need to mutate/set the value - then use let; even then consider using a new const if you can. Don't touch var like it's got an infection, I can't remember the last time I had to use it.

    • @Minty_Meeo
      @Minty_Meeo 7 หลายเดือนก่อน +12

      I wish more C/C++ writers were const correct whenever possible.

    • @adityaanuragi6916
      @adityaanuragi6916 7 หลายเดือนก่อน +35

      Unless you need to mutate?
      You can mutate arrays and objects even if they are const,
      const arr = [10,20]
      arr.push(30) works

    • @bgdgdgdf4488
      @bgdgdgdf4488 7 หลายเดือนก่อน +55

      ​@@adityaanuragi6916just becaude you can, doesn't mean you should. Const keyword tells something to the code reader.

    • @erickmoya1401
      @erickmoya1401 7 หลายเดือนก่อน +20

      This. Like kids game. You ever write var you die. Never ever do it.

    • @yueguifan
      @yueguifan 7 หลายเดือนก่อน +14

      Rust programmers be like

  • @DK-ox7ze
    @DK-ox7ze 7 หลายเดือนก่อน +73

    Ah, the good old days of tricky js interview questions.

    • @ninhdang1106
      @ninhdang1106 7 หลายเดือนก่อน +8

      It’s still used for entry level interview. I remember having a hard time explaining “why var sucks” just because I proactively chose not to use it lol

    • @ollivainionpaa684
      @ollivainionpaa684 7 หลายเดือนก่อน +3

      Yes very tricky. Using variable before defining it. Would just spit on the face, laugh and leave if that wouldn't be the sought answer.

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

      that is not tricky lol. most js interview questions are harder than this

  • @micheledelzoppo13
    @micheledelzoppo13 7 หลายเดือนก่อน +42

    Thanks for letting me know before I end up messing up in the future 😅

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

      just never use var, i've never found a reason to use it.

    • @LosFarmosCTL
      @LosFarmosCTL 7 หลายเดือนก่อน

      @@squidy2902yup there is no legitimate reason to use it, if anyone at any point tells you that there is, they are wrong 😂

    • @MrRagday
      @MrRagday 7 หลายเดือนก่อน

      Var and future)))

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

      don't worry you'll still mess up, all is well : D

  • @FloWoelki
    @FloWoelki 7 หลายเดือนก่อน +27

    i love to use const first and then adjust later with let, if needed (like in Rust, having immutability first and then adjust).

    • @Dylan_thebrand_slayer_Mulveiny
      @Dylan_thebrand_slayer_Mulveiny 7 หลายเดือนก่อน +1

      You can't override a const. Const means constant. As in cannot change. You have no idea what you're talking about.

    • @FloWoelki
      @FloWoelki 7 หลายเดือนก่อน +9

      ​@@Dylan_thebrand_slayer_Mulveiny i never said that i can override const :D i've just said that i would use const first, and adjust later with let.

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

      Well try this:
      For placeholder variables like arr, obj etc use let because along the way they'll be updated
      const for like loops or callbacks fxns

  • @AnastasiyaSoyka
    @AnastasiyaSoyka 7 หลายเดือนก่อน +63

    Praise Cthulhu, and his favorite programming language, JavaScript.

    • @Templarfreak
      @Templarfreak 7 หลายเดือนก่อน +1

      ah that makes sense. this feature probably only works for a being such as Cthulhu who doesnt care about the constraints of spacetime at all.

  • @cinderwolf32
    @cinderwolf32 7 หลายเดือนก่อน +21

    "does your code suck"
    I fixed a display issue the other day by adding a 0ms setTimeout.

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

      Technically that actually does delay your code a bit. I'm not sure if it's a microtask or having it to somewhere else in the queue. But there is a whole set of things that occur when you set timeout to zero and promise and immediately resolved it. Those like an entire algorithm for how to handle those things

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

      I once fixed buggy code at a new job. Previous Dev tried to fix issues by using multiple timeouts. Page ended up loading 3 seconds faster. I got a 13k$ bonus that year. :)
      So I guess I have to thank guys like you.

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

      "I have no idea WHY this works, But it does, So just don't touch it"

    • @Lumither-404
      @Lumither-404 2 หลายเดือนก่อน

      So basically running code in new thread ?

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

      @@Lumither-404 There is only one thread in a browser. Using setTimeout will put its callback function in the event loop stack to be called later. Sometimes this delay is sufficient for code this callback function depends on to be evaluated. Search for "Race condition in JavaScript".

  • @kebien6020
    @kebien6020 7 หลายเดือนก่อน +19

    The TDZ is temporal, as opposed to scope-based. i.e. You can use your variable before it's defined in code order, as long as by the _time_ hou need it, it's been defined.
    function logX() {
    console.log(x)
    // ☝️ refers to the x below thanks to hoisting
    }
    let x = 15
    logX() // prints 15 just fine

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

      one javascript snippet a day keeps the motivation to do webdev away 😭 wth is that shit how can a closure capture a variable before it is defined (i know you explained why but who tf though it’s a good idea lmao)

    • @isometric_shahil
      @isometric_shahil 7 หลายเดือนก่อน +1

      That's very interesting, thanks for sharing this

    • @adam7802
      @adam7802 7 หลายเดือนก่อน

      @@LosFarmosCTL Thankfully scoped variables and arrow functions exist so you can just pretend this doesn't.

    • @kebien6020
      @kebien6020 7 หลายเดือนก่อน +2

      @@adam7802 You're misunderstanding. This applies _specifically_ to scoped variables (TDZ only applies for let and const variables). And it's _more_ relevant if you use arrow functions. e.g.
      console.log(plus(5, 3)) // prints 8
      function plus(a, b) {
      return a + b
      }
      Compare to:
      console.log(plus(5, 3)) // TDZ error
      const f = () => console.log(plus(5, 3))
      const plus = (a, b) => a + b
      f() // works fine

    • @adam7802
      @adam7802 7 หลายเดือนก่อน

      @@kebien6020 I meant more in general rather than this specific issue. Although I didn't know that would work... Javascript is such a mess.

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

    No, my code does not suck. Javascript does.

  • @andreujuanc
    @andreujuanc 7 หลายเดือนก่อน +45

    I can't tell because I can barely see the screen when TH-cam puts buttons, labels, and other bs all around and blocks everything.

    • @redrush-hp9li
      @redrush-hp9li 7 หลายเดือนก่อน

      How small is ur phone?

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

      @@redrush-hp9li size is not important

    • @mastermind4193
      @mastermind4193 7 หลายเดือนก่อน +3

      @@andreujuanc tell this to your GF

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

      Someday the video will just be an animated background for a grid of buttons.

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

      i have the same problem both on the phone and on the computer

  • @jorionedwards
    @jorionedwards 7 หลายเดือนก่อน +5

    I know nothing about javascript and just guessed that var does something funky based on my minimal Rust experience.

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

    Not me realising this was the error I spent several hours on a couple of months ago (and gave up on).
    Thanks Fireship, very cool.

  • @emrescript
    @emrescript 7 หลายเดือนก่อน +40

    currently this comment section is the only thing that is worse than var.
    On second thought-

  • @MichaelSt
    @MichaelSt 7 หลายเดือนก่อน +63

    It’s not the code that sucks at this point it’s JavaScript itself

    • @NorthLaker
      @NorthLaker 7 หลายเดือนก่อน +8

      It's the necessity for backwards compatibility that makes it suck. Programmers just didn't know how to write clean code back in the early days :)

    • @additionaddict5524
      @additionaddict5524 7 หลายเดือนก่อน +2

      have a decent linter and you'll stick to a subset of js that doesn't suck

    • @divinecomedian2
      @divinecomedian2 7 หลายเดือนก่อน

      Always has been

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

      What do you mean ? the code is non-sense but JavaScript handled it quite well throwing reasonable output.

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

      It's bad, but I had a C++ class and it felt like 80% of the language is forbidden territory.

  • @salmanazam9444
    @salmanazam9444 5 หลายเดือนก่อน +2

    I started learning JS a few months ago and initially would only use var. I thought it was very convenient to make everything of global scope. But I stopped using it completely in a month or two because I realized its actually more convenient to have variables only take local scope.
    Been using const almost exclusively since then.
    Btw, I like JS. I liked it from the start. Yes, its very messy and you get the impression that it got more features without being made 'neater', but its really versatile and powerful. And yes, my code does suck. I make things too difficult. Whatever practice/learning I'm supposed to do, I think of some way I can make it ten times more complex, just to do some extra stuff.

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

      Thats the way my friend. We all had this journey until we get to know stuff better ^^ In coding, skill comes with experience

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

    The error is not 'a is not defined' it will be ' can not access a before initialisation '

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

    Good one, I knew the var would hoist but I didn't know the value assignment would be executed after the log. I think even with a 100 years of JS experience one can be surprised from time to time.

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

    Except for the part where javascript errors occur only at run time, so if that code is rarely executed, its gonna be a pain to fix

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

    Not really "after the declaration" but "after the declaration has run"
    If you have a function above the declaration but it only gets called after the declaration, it works fine

  • @whoman0385
    @whoman0385 7 หลายเดือนก่อน +11

    what are these comments man 🙏

    • @KevintheRhea
      @KevintheRhea 7 หลายเดือนก่อน +1

      Right? Lmfai

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

    I like and doslile js at the same time. It's easy but it also lets a lot of no go stuff go through until it breaks at some point.

  • @loktar00
    @loktar00 7 หลายเดือนก่อน +2

    No one uses var anymore anyway there's nothing it provides over let or const to justify it's usage.

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

    " that can easily debug" get me😅

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

    When a language is less consistent and more confusing than literal undefined behaviour, you know you've messed up somewhere.

  • @blauesaxolotl
    @blauesaxolotl 2 หลายเดือนก่อน +1

    Does your code suck ❌️
    Does your programming language suck ✅️

  • @KaramAlayan
    @KaramAlayan 7 หลายเดือนก่อน +2

    Brother this isnt "does your code suck"
    Its "does Javascript suck ?"
    And ill be proud to answer YES YES IT SUCKS

    • @MrRagday
      @MrRagday 7 หลายเดือนก่อน

      Seems like you know almost nothing about js, am i right?

  • @jellyface401
    @jellyface401 8 วันที่ผ่านมา

    Repeat with me: Javascrip was created to interact with the DOM of html web pages in that context this makes sense. We should not use forks to drink soup even if we managed to make with one of those spoons that have fork like heads

  • @KarlLew
    @KarlLew 7 หลายเดือนก่อน

    Lol. Thanks for articulating why I stopped using var. I got hoisted too much for my liking and tossed that out a while back.

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

    you can still debug the undefined thing (at least in Firefox, I don't use chrome)

  • @p0r5ch3911
    @p0r5ch3911 7 หลายเดือนก่อน

    What's really bad is that some people thought it's a feature and used this intentionally to write their code.

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

    This is cool. I know JS and understand hoisting. I just subconsciously never use 'var' and instead use 'let' or 'const' depending on what I need.

  • @philiptheplant
    @philiptheplant 7 หลายเดือนก่อน +4

    how about not using a variable before declaring and initializing it like a normal person? when did common sense leave JS?

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

      Mistakes happen. Code may have moved. The partial hoisting is bonkers anyway.

    • @Templarfreak
      @Templarfreak 7 หลายเดือนก่อน

      @@lgasc while both of your points are very true, there are some key things to consider.
      saying it is "common sense" is pointless and meaningless. "common sense" is different for every person and thus doesnt really exist. scoping is done all over the place in all kinds of different languages and sometimes it can be hard to keep track of how all your scoping is set up and is working within the rules of whatever language you are using. and that's what this is, it's a scoping issue.
      but this also is just a bad idea to ever have in a coding language, period. it literally only creates unintuitive and completely hidden behavior that you basically have no way of figuring out without pure trial and error or having someone else explain it to you if you have no idea what is going on. it should never be a thing because all it is is a pointless barrier to entry as it is a small but annoying piece of information to know about javascript that is also largely useless information to have other than to just avoid it, as hoisting in general is an extremely situational thing to take advantage of

  • @theilluminatimember8896
    @theilluminatimember8896 7 หลายเดือนก่อน +14

    I always use let ever since it became popular, but now I see why it got popular. I probably don't even realize how many headaces I've dodged

    • @MrRagday
      @MrRagday 7 หลายเดือนก่อน

      Not many actually. You just avoid 1 concept

  • @frontend3409
    @frontend3409 7 หลายเดือนก่อน +4

    2005 called and he wanted his var back

  • @akulgoel9259
    @akulgoel9259 4 หลายเดือนก่อน +1

    "does your code suc-"
    yes it does

  • @nunchukGun
    @nunchukGun 7 หลายเดือนก่อน

    This explains the time i fixed something by switching let to var 😂

  • @sobanya_228
    @sobanya_228 ชั่วโมงที่ผ่านมา

    I don't quite get how it's a nightmare to debug. You get what you see

  • @pixel690
    @pixel690 7 หลายเดือนก่อน

    i still remember i had a very very strange bug that fixed itself through using var rather than let
    i cant remember what the bug was
    but jesus christ

  • @CascadiaNow69
    @CascadiaNow69 4 หลายเดือนก่อน +1

    Aha!! I got it right! I’ve been studying JavaScript for like 7 hours total! I am so fucking smart!!!

  • @privacyvalued4134
    @privacyvalued4134 29 วันที่ผ่านมา +1

    I only use var. That's because I'm awesome at writing software and don't use variables before I've declared and assigned them a value. Your code might suck though.

  • @bawbsmith
    @bawbsmith 7 หลายเดือนก่อน +1

    Ngl the TH-cam shorts interface is shit. I didn’t realize the difference cuz “var” was partially covered, and there’s no way to hide the buttons over the video

  • @Sycro11
    @Sycro11 7 หลายเดือนก่อน

    i cant see the second code because of the shorts text lol and now im struggling to send this message because the message button dissapeared. I love yt

  • @yah5o
    @yah5o 7 หลายเดือนก่อน +1

    Imagine running this abomination of a programming language not only in the browser but also server-side. Oh…wait…

  • @johnbrooks7350
    @johnbrooks7350 7 หลายเดือนก่อน +1

    Ya know… when I hear JS being a trash fire of weird language mechanics, I used to think they were exaggerating.

  • @BlueBearOne
    @BlueBearOne 3 หลายเดือนก่อน +1

    I respect and greatly appreciate your work so much. I'd love to have a countless number of these as I start my journey into JavaScript. Either way, THANK YOU!

  • @itjustcrashed
    @itjustcrashed 3 หลายเดือนก่อน +1

    Bruh swift is like: THE ERROR IS *RIGHT THERE* do you SEE IT???!!!!!???!?!?!??!!!???

  • @APerson-14
    @APerson-14 2 หลายเดือนก่อน +1

    Good to know this.
    I knew it was B
    Simply because var is automatically stupid

  • @thatJackBidenTalksAbout
    @thatJackBidenTalksAbout 7 หลายเดือนก่อน

    JavaScript's lava flow quirks are what make it fun. Especially compared to C++, where template metaprogramming has made everything just...just awful.

  • @jasonsimpson1609
    @jasonsimpson1609 4 หลายเดือนก่อน +16

    Is your code JavaScript? Then it sucks.

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

      How in the living fuck do I make my websites function then?

    • @privacyvalued4134
      @privacyvalued4134 29 วันที่ผ่านมา

      @@RealUniCat Static HTML content. As mother nature intended. That's how.

    • @RealUniCat
      @RealUniCat 29 วันที่ผ่านมา

      @@privacyvalued4134 ??? What if I wanna make a game in JavaScript?

  • @TechnoSan09
    @TechnoSan09 3 หลายเดือนก่อน +1

    Totally quitting var keyword and using typescript is one of the best decision in my life

  • @arunsp767
    @arunsp767 7 หลายเดือนก่อน +1

    Nah I'm good. I have never in my life expected a variable to hold a value before declaring it

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

    One shouldn't even use "var" anymore. The keyword "let" is more cool.

  • @alexlopez5800
    @alexlopez5800 7 หลายเดือนก่อน +1

    Yet, someone's job is to de-bug these lines of code that they copy and paste in. Starting wage with 10,000 years experience = 100k

  • @AslamNazeerShaikh
    @AslamNazeerShaikh 7 หลายเดือนก่อน +1

    JS will disappear soon.. WASM is future🎉

  • @xGreenhero
    @xGreenhero 7 หลายเดือนก่อน

    I do angular and typescript. And did a JS interview and failed it… cause a lot of the questions, are situations i wouldn’t run into when i use typescript.

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

      You may want to look into it; Typescript is not always available.

  • @OctagonalSquare
    @OctagonalSquare 7 หลายเดือนก่อน

    Wait, what??? Why did I never learn that it moves the declaration? It hasn’t really affected anything for me, but that’s more happenstance than because I am a good dev.

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

    but what kind of dev put his declarations at the end of his code? Var is neat, all you need is good practice...

  • @Spencer-wc6ew
    @Spencer-wc6ew 7 หลายเดือนก่อน +1

    What is confusing about a not being 1 before "a = 1"!

  • @crimsondragon2677
    @crimsondragon2677 2 หลายเดือนก่อน +1

    You live like this?
    (Python and C++)

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

    Programming is something, i will never feel secure to say im good at it. Like literally never.

  • @christianremboldt1557
    @christianremboldt1557 7 หลายเดือนก่อน +1

    I didn't know the difference between _let_ and _var_
    Good to know. Another reason why JS sucks

    • @MrRagday
      @MrRagday 7 หลายเดือนก่อน

      Difference is simple. You should use let and should not use var

  • @AlejandroDahlgren
    @AlejandroDahlgren 7 หลายเดือนก่อน +1

    I'm new... dont make me feel bad before i learn more.

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

    JavaScript's errors are neither nice nor clear.

  • @harsh.vision
    @harsh.vision 7 หลายเดือนก่อน +1

    Hoisting is important in jetpack compose in Native Android

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

    It's crazy people I've worked with still use var 💀

  • @_sevelin
    @_sevelin 7 หลายเดือนก่อน

    Funny when we talk about js code sucking, we mostly talk about runtime errors and not compile time.

    • @SirusStarTV
      @SirusStarTV 7 หลายเดือนก่อน +1

      Because js isn't compiled language

    • @_sevelin
      @_sevelin 7 หลายเดือนก่อน +2

      @@SirusStarTV Yeah frick that actually makes sense. After so much of using TS, I forgot that little tiny detail...

  • @roteklaue1311
    @roteklaue1311 7 หลายเดือนก่อน +1

    Simply using var is already bad.

  • @madskaddie
    @madskaddie 7 หลายเดือนก่อน +1

    a general rule, scopewise, const > let > var > global.
    but var and global do have their use cases.
    the example is so simple that const is the "right answer" and both samples "suck" 😜

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

    I like this

  • @vectoralphaSec
    @vectoralphaSec 7 หลายเดือนก่อน +1

    JS is such a horrible language.

  • @ouwyukha
    @ouwyukha 7 หลายเดือนก่อน +1

    you can rename to Let's Play: Do you use ESLINT

  • @TheVergile
    @TheVergile 7 หลายเดือนก่อน

    and why exactly would you WANT to initialize a variable somewhere in the middle of any given scope?

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

      If you use a variable only for a short part, it is simpler to put the variable before it rather than all the way to the top.

  • @eboatwright_
    @eboatwright_ 7 หลายเดือนก่อน +1

    Bruh

  • @mpty2022
    @mpty2022 7 หลายเดือนก่อน +1

    the bottom part, cant really read anything because of this great gui by youtube covering about 60% of the acreen

  • @ArnoldsKtm
    @ArnoldsKtm 7 หลายเดือนก่อน +1

    if anyone still uses var these days, that's a skill issue

    • @midoevil7
      @midoevil7 7 หลายเดือนก่อน

      Using javascript IS the issue

  • @themore-you-know
    @themore-you-know 7 หลายเดือนก่อน +13

    A situation where sucky code is made possible by a sucky language/environment.
    Imagine if learning to drive, and driving itself, was injected with random problems such as your engine blowing up if you ever make the mistake of shifting the radio station too fast. And god forbid you ever pump the brakes twice.

    • @ra2enjoyer708
      @ra2enjoyer708 7 หลายเดือนก่อน

      What language do you write at?

    • @mgord9518
      @mgord9518 7 หลายเดือนก่อน +4

      I'm fully convinced that people who like JS are all people who started their programming journey with JS and refuse to try literally any other language in existence

    • @mgord9518
      @mgord9518 7 หลายเดือนก่อน

      ​@@ra2enjoyer708Go, Python, C, Zig, sh
      Even shell scripting, which is known for being hard to debug makes way more sense than the stupid rules of JavaScript

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

    Bro, I don't even know JavaScript but I chose the B because it had var and I thought it said variable.

  • @UGPepe
    @UGPepe 7 หลายเดือนก่อน

    hoisting is fine and useful and not confusing at all, it's just zoomers, everything is confusing to these people

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

    The semicolon left the chat

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

    Wait but JS is a top to button language so how it is possible that it's knows there is vat there and put it on top it's jot suppose to give error too ?

  • @MrCmon113
    @MrCmon113 7 หลายเดือนก่อน

    Every programming seems to come with these puzzling, unintuitive configurations.

  • @dotanuki3371
    @dotanuki3371 7 หลายเดือนก่อน

    Let's play, does your language suck? Is JS one of Biden's approved languages?

  • @xsthetic
    @xsthetic 7 หลายเดือนก่อน +1

    the error itself sucks : 'a is not defined' yet the language itself has an 'undefined' value which basically means the variable is not defined

    • @SirusStarTV
      @SirusStarTV 7 หลายเดือนก่อน

      console.log(x);
      Uncaught ReferenceError: x is not defined
      console.log(window.x);
      undefined
      When you access global variable through a property access expression it doesn't throw error

  • @BobChess
    @BobChess 7 หลายเดือนก่อน

    I answer wrong because I don't use JS (it's bad and I use python to make webs)

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

    Just don't use var! We have let and const now! Just forget it exists!

  • @theweebtoblame5402
    @theweebtoblame5402 7 หลายเดือนก่อน +12

    Your code DOES suck.

  • @tacticalassaultanteater9678
    @tacticalassaultanteater9678 7 หลายเดือนก่อน +1

    There's a very annoying class of JavaScript developers who internalized the lack of errors and will insist that the fewer incorrect code samples produce errors, and the later those errors surface, the better.

    • @privacyvalued4134
      @privacyvalued4134 29 วันที่ผ่านมา

      You forget that Javascript was a hack to enable dynamic functionality in a web browser. Functionality that probably should never have existed. Oh, BTW, I use var.

  • @sadjadasadi4575
    @sadjadasadi4575 7 หลายเดือนก่อน +1

    That's why it's always suggested to either use let and const

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

    I knew which one was bad because of lint :) But I didn't know why!

  • @newshyne
    @newshyne 4 หลายเดือนก่อน +1

    And you also have to write "use strict".

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

    I would like to see JS gone forever
    But we are a little too far from that now

  • @cinderwolf32
    @cinderwolf32 7 หลายเดือนก่อน

    Pausing to see if my knowledge is still expert level: the var hoists the declaration, meaning the variable should be null when logged.
    Edit: crap! Undefined. It has been a while since I have used JS much. Well, thats why I never use var.

  • @OneAngrehCat
    @OneAngrehCat 7 หลายเดือนก่อน

    IMO, JS had a deserved reputation for being an anus' deepest part until ES6.
    Let and const and all the scoping and cleanup options that it brought made it viable.
    Typescript later made it reliable.
    Modern JS doesn't deserve to be called crap for the most part.

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

    Thats also the reason, why "let" was introduced. ja ist full of Bad design decisions, but you cannot change them, without breaking existing code
    And yeah, many bad developers rely and this bad decisions... So js must constantly introduce new constructs

  • @CodeRedsGames
    @CodeRedsGames 7 หลายเดือนก่อน

    Something that had me almost strangle myself for contributing to a JS project, were default exports. Who the fuck wants to import a function or class and assign it another name so you won't ever find the right definition when searching by text. FFS