Differences Between Var, Let, and Const

Поділитися
Вставка
  • Опубліковано 2 гру 2024

КОМЕНТАРІ • 218

  • @ianoliver6828
    @ianoliver6828 3 роки тому +239

    You have a super rare skill. It's rare to find someone who is both a skilled programmer AND a skilled teacher / communicator. Thank you for your videos

  • @camilafloressanhueza7966
    @camilafloressanhueza7966 4 роки тому +154

    OMG!! I had seen 100000 videos whose explanations were extremely complicated, but you explained it in less than 5 minutes!! Thank you very much

  • @Max-nm8ct
    @Max-nm8ct 3 роки тому +42

    Mate, I must say, your hair is on fleek!

  • @TheSlimSh4dy
    @TheSlimSh4dy 4 роки тому +11

    Thank you for the clear explanation! Currently, I'm learning HTML, CSS & Javascript and if I don't understand something, I'm firstly looking at your channel to find an explanation. If it doesn't exist on your channel, then I'm searching in other sources. You are a very good teacher, your videos are short, consistent and very clear, without any unnecessary content. Thank you very much for sharing your time to make these videos.

  • @dorothyglade9087
    @dorothyglade9087 3 роки тому +1

    This was great, you speak at just the right speed and your voice is clear. This really helped me and my husband with something in our bootcamp.

  • @jthomasaurus
    @jthomasaurus 4 роки тому +6

    Another super-clear explanation. Love your video style, brevity, and way of explaining everything. Plain and simple!

  • @LeHuffy
    @LeHuffy 6 років тому +8

    This video came just in time. We are going through Javascript and JQuery right now in my bootcamp!

    • @WebDevSimplified
      @WebDevSimplified  6 років тому +3

      I'm really glad to hear. If you run into anything that confuses you in the bootcamp feel free to let me know, and I can try to help or make a video on the topic.

    • @LeHuffy
      @LeHuffy 6 років тому

      @@WebDevSimplified Awesome will do!

  • @AlexTechie
    @AlexTechie 6 років тому +60

    6:36 I didn't know that. This is why I always watch your videos, even if I think I understand the subject before hand. Great work! 👍

    • @WebDevSimplified
      @WebDevSimplified  6 років тому +13

      It is a bit counter intuitive based on the name. You can use Object.freeze to create an object that cannot have the properties reassigned, but it will still let you reassign a nested property such as company.ceo.name = 'New name'

    • @AlexTechie
      @AlexTechie 6 років тому +4

      @@WebDevSimplified thanks for the tip! As I was watching the part I referenced earlier, I was wondering how we would assign constants to the properties of an object, so it's like you read my mind. :D

  • @tonic.9234
    @tonic.9234 2 роки тому +1

    I never knew var worked like this, and I've been using Javascript almost daily for over 2 years. I always assumed it worked like let because I have a background in other programming languages and assumed it's scoping worked the same. So wild! Thanks for the clarification!

  • @dsvhs93
    @dsvhs93 4 роки тому +1

    Whenever Kyle comes out with the JavaScript class that he is working on.... I am purchasing it. He is awesome! Thank you Kyle!

    • @WebDevSimplified
      @WebDevSimplified  4 роки тому

      Thank you for the support! I start recordikg tomorrow!

  • @pratikthorat3480
    @pratikthorat3480 3 роки тому +1

    This is the best explanation I've ever seen. I do know the differences yet I learnt something new

  • @moonlightCR7
    @moonlightCR7 Рік тому

    Thanks a billion, Kyle for explaining the difference among these keywords.

  • @dozadetrezire7455
    @dozadetrezire7455 2 роки тому +25

    You forgot to say one more thing: when you declare a variable with var keyowrd, this automatically creates a property inside the Window ojbject.. so, if you say for example: var x = 1; and after that you say: console.log(window)... you will see that in the window object you will find the property X with the value of 1. Instead, if you declare a variable with let or const, this won't ceate a property inside the Window object. I guess this was also very important to mention!

  • @rohit9969171579
    @rohit9969171579 5 років тому +11

    It was very crystal clear explanation thank you.

  • @sagarioharvey6910
    @sagarioharvey6910 2 роки тому

    Web dev here in the PH. "Man I love your videos, your making a great impact" //awesome

  • @raaghavendrahm4883
    @raaghavendrahm4883 3 роки тому

    I am just starting with JS and I was stuck with this like hell. You made it so clear. Thanks a lot!!

  • @AidanJoyce
    @AidanJoyce 2 роки тому +2

    Would like to say, well done and thank you for a clear and concise explanation of the similarities, differences and when to use, Var, Const and Let.
    Watched other videos and without doubt, you nail it better here with both explanation and example.
    Will be watching more of your stuff as this was a great measure stick for the quality of teaching.
    Keep up the great work.

  • @michaelmaloy6378
    @michaelmaloy6378 Рік тому +1

    Whenever I see that face, I know useful information is coming my way.
    Simple, clear, and very helpful. Thank you as always!

  • @pooja6380
    @pooja6380 2 роки тому +1

    learn so much important points and the actual difference ....thanks a lot

  • @santra528
    @santra528 4 роки тому

    This is complete explanation of let vs const vs var I have ever seen. Thanks Kyle 😊

  • @jahneychriast2141
    @jahneychriast2141 4 роки тому +2

    தெளிவான விழக்கம் நன்றி 🙏🏽

    • @manojbharadwaj456
      @manojbharadwaj456 4 роки тому +2

      That's so motivating. Because nobody understood that!

  • @gqntexas
    @gqntexas 3 роки тому

    Great great explanation.. you always here that the differences is the 'block scope' and then wonder, well, like within an if or for loop, but nobody else ever says that...

  • @videospromoter5884
    @videospromoter5884 4 роки тому

    Checked 10s of video and this video told me hmm you understand this now . say thanks to him :) Thanks Dude

  • @therealbrucewayne24
    @therealbrucewayne24 2 роки тому +1

    Yes I did learn something thank you very much man it was hard for me to understand this but you explained it in like less than 10 minutes lol you have a good day too :)

  • @sandybathwater8385
    @sandybathwater8385 3 роки тому

    So simple, thank you so much! If I search for something and see your face in the results, I am saved. :)

  • @dacfniel5442
    @dacfniel5442 4 роки тому

    You are the best teacher on UA-cam.

  • @thecoderabbi
    @thecoderabbi 3 роки тому +1

    Thank you very much Kyle, This is great. Very explicit. I think I would begin using the 'const' instead of the 'var'
    Thanks ✌️

  • @coderbhai4832
    @coderbhai4832 3 роки тому +23

    1)Declaration Let variable in a {} block scope can't be access outside of it
    2)let name = value1, let name = value2, can't redeclare let twice
    Instead of this should be written name=value2;
    3)let can be change it’s value const can't as it is constant but it can change its object value.🙃

    • @chalk1007
      @chalk1007 2 роки тому

      yeah, I was a little confused aswell but this video was made in 2018

    • @dozadetrezire7455
      @dozadetrezire7455 2 роки тому +1

      You forgot to say one more thing: when you declare a variable with var keyowrd, this automatically creates a property inside the Window ojbject.. so, if you say for example: var x = 1; and after that you say: console.log(window)... you will see that in the window object you will find the property X with the value of 1. Instead, if you declare a variable with let or const, this won't ceate a property inside the Window object. I guess this was also very important to mention!

  • @derrick3534
    @derrick3534 5 років тому +5

    man you are teaching the things that are not widely discussed which is why i am going to subscribe. You have a true gift of teaching in simple terms. i enjoy your channel, especially the tutorial on promises

    • @WebDevSimplified
      @WebDevSimplified  5 років тому +2

      Thank you! I try to cover the topics that I know confused me or other people I know, because those will be the most helpful for others.

  • @jorgefrias7889
    @jorgefrias7889 Рік тому

    Amazing explanation. Simple and straight to the point. Thank you!

  • @bujjivenkateshwarlu6942
    @bujjivenkateshwarlu6942 3 роки тому

    Hey thanks. earlier i had confusion about block scope and Function scope. Now its cleared.

  • @samanthawu1637
    @samanthawu1637 3 місяці тому

    You were born to teach! Awesome!

  • @theNikijspictures
    @theNikijspictures Рік тому

    Really good explanation, for beginner level - if reading info only in text (with no visual examples), it gets confusing quickly on this topic. Cheers😉

  • @EyeIn_The_Sky
    @EyeIn_The_Sky 3 роки тому +2

    Good old Java script, Let (no pun intended) us introduce "const" that does not allow for re-assigning to avoid human error so that it is "constant" except when it's not...

  • @ImHansana123
    @ImHansana123 7 місяців тому +2

    The good old days when we didn't have chatgpt.❤️

    • @WebDevJapan
      @WebDevJapan 6 місяців тому

      lol true, but I like seeing a human explain it sometimes. Even though I can get quick answers from Professor GPT, I've made it a habit to watch one short intructional video like this everyday.

  • @aadityakiran_s
    @aadityakiran_s 2 роки тому

    I came from C#. It's pretty simple there. Use var for what you wanna change, const for what you don't wanna change; variable and constant. Simple language for simple people.

  • @tiltify2393
    @tiltify2393 3 роки тому

    finally I understand the difference, thanks man A LOT

  • @borislavaborisova7274
    @borislavaborisova7274 Рік тому

    Thank you! This video was very helpful. Just what I needed.

  • @stuartgreen5217
    @stuartgreen5217 4 роки тому

    Been building sites for 30 years and always avoided JS due to pre jquery experience. Am now taking the time to relearn JS and node while I’m at it and I have to say I’m regretting not doing this sooner. I’ve been programming in C# php Perl VB and JS is a peace of cake by comparison .

  • @injector6926
    @injector6926 3 роки тому

    Best Web Development I seen evrr

  • @guillaumedupont2902
    @guillaumedupont2902 4 роки тому

    This was SO helpful. Thank you so much!

  • @СашаТюменцев-ш9ь
    @СашаТюменцев-ш9ь 2 роки тому

    huge thanks for the explanation, only you made it clear to me!

  • @baliyachtservices7505
    @baliyachtservices7505 2 роки тому

    I was wondering just that! Thanks so much

  • @rajlakshmijoshi
    @rajlakshmijoshi 2 роки тому

    Thnks for the detailed vid, just one correction: At 5:35-> const does not allow to 're-declare' the variable, actually should be const does not allow to 're-assign' the variable, but let do.

  • @nessparadis6948
    @nessparadis6948 Рік тому

    Great video. Succinct, clear to understand, and I learned a lot. Thank you.

  • @khisus20
    @khisus20 2 роки тому

    This is truly simplified

  • @aisana99
    @aisana99 2 роки тому

    thank you :D you shared more differences than my constructor in my Full-Stack Bootcamp! Will subscribe and watch all other videos of yours

  • @bozok1903
    @bozok1903 3 місяці тому

    Very clear explanation. Thank you for that.

  • @rickneibauer1
    @rickneibauer1 2 роки тому

    I can't move on until i know why something works unless i ABSOLUTELY have to. thanks to you i can move toward the light. goodbye everyone...

  • @JEffinger
    @JEffinger 2 роки тому

    Thank's bro that was a really clear explanation.

  • @khaktus
    @khaktus 2 роки тому +1

    While I prefer Kyle's tutorials over the others for various reasons (extent > clarity > simplicity), for this one I'll differ from the praise-storm below - this was just one of the many confusing explanation of the var|let|const topic that I've seen so far.
    This is the problem that many skilled developers have - they assume that as developers they have analytical thinking and provide well structured explanations (naturally, by default) - but I have seen - since the university times to professional days - that the paradoxical situation happens: techies often do the exact opposite: they do not adhere to the structure/hierarchy of the topic, nor the consistent use of terms they set in the beginning. :D Something to work on throughout professional life.
    In first part, you repeatedly state that var does and let does not allow to redeclare the variable, then you say the difference between let and const is that const does not allow to redeclare the variable. That paused my brain, while explanations went on. Maybe stating more clearly what is the difference between (your use of) "redeclare" and "redefine" and "reset" and "reassign" ... would help. Particularly in this one topic. :)
    I'd welcome more "technical" "analytical" (or tabular ;) ) than the "narrative" approach here. And particularly a consistent use of terms.
    1 minute:
    redeclare:
    var|let|const myThingy = 10
    var|let|const myThingy = 20
    redefine/reassign/reset variable value:
    var|let|const myThingy = 10
    myThingy=20
    redefine object|array items value (not object|array value, which is just its memory address, so that remains "constant"):
    var|let|const myObject = [10, 11];
    myObject[0] = 20
    1 minute:
    | redeclare| reassign value of variable | reassign value of item in the array or property in the object|
    ------------------------------------------------------------------------------------------------------------------------------------------------------------
    var yes yes yes
    let no yes yes
    const no no yes
    Also, from the many lessons on the scope, I understood that "scope" is something defining on what level of nesting we are (regardless if it is a function or block or just anything between {}). This perspective was often emphasized. Here, for the first time, I hear that different scope is actually defined by either function or block. Good point here!

    • @nowhererealm
      @nowhererealm 2 роки тому

      dude yes! I was wondering how the heck are there so many people praising the explanation when i couldnt understand why he said let cant redefine a variable then goes on and says thats the only difference between const and let?? lmao wtf

  • @itsshafayat6378
    @itsshafayat6378 6 місяців тому

    someone get this absolute master a stellar coding setup i.e a better keyboard

  • @sadhappy8860
    @sadhappy8860 Рік тому

    Super clear explanation, many thanks

  • @oceanmind1793
    @oceanmind1793 2 роки тому

    You made it so clear. Thanks a lot

  • @weligamage1
    @weligamage1 2 роки тому

    Clear and concise, Thank you

  • @NashBrooklyn
    @NashBrooklyn 2 роки тому

    wait up! const also allows to assign value outside of block - as many times you would need to assign such value that cannot be changed by hackers - for instance a waiting time to acept a trip request must be 1 minute only - so if a hacker wishes to change that to 60 minutes - const will not let that to happen - const is great to use in many solid inflexible math routines - that can happen all over the code - so if you set the earth radius to its value as per books - then using const will assure it wont be changed by any accidents or bugs in code -

  • @wr1818
    @wr1818 3 роки тому

    thankyou for all the amazing explaining!

  • @somtovitus
    @somtovitus 3 роки тому

    Best video on this topic

  • @nobitalazy9791
    @nobitalazy9791 2 роки тому

    you are a rare gem my friend!!!

  • @ev_dash
    @ev_dash 2 роки тому

    Your videos are helping me out alot! Thank you ❤

  • @xilliman
    @xilliman 3 роки тому

    im declaring every variable as const and then change it to let if i have to reassign them. this makes the code much safer. i don’t use var anymore

  • @kazeemalatishe3828
    @kazeemalatishe3828 3 роки тому

    Thanks a lot. You explain things really well.

  • @priyanshugupta7614
    @priyanshugupta7614 Рік тому

    thank you your explanation was very clear

  • @mirceahanghiuc4447
    @mirceahanghiuc4447 3 роки тому

    A nice topic can be this :
    function justA(){
    a = 1;
    }
    justA();
    console.log(a); // 1

  • @derickbank1064
    @derickbank1064 3 роки тому

    Thank you for the explanation. Well explained. !

  • @JonasGavenas
    @JonasGavenas 2 роки тому

    Great lesson!
    Thank you, perfect explain.

  • @alex_blue5802
    @alex_blue5802 Рік тому

    I used to see people saying that you should use const only if you have a specific need for a variable to remain constant. Nowadays it seems like people always want to use const as a default and I don't like that as much.

  • @pashashyba5006
    @pashashyba5006 2 роки тому

    Quite easy to understand. Thanks

  • @NedumEze
    @NedumEze 3 роки тому +1

    I love your approach so much. Thank you.
    I do have a fundamental problem though. Maybe you can consider making video of it. It is this:
    When I create an external JS file, and I have in it, codes like functions, etc in it, only the first code or function works!
    What should I do to ensure that different codes intended to fire at different Listeners, in the same file, work?

  • @RS-nz6rn
    @RS-nz6rn 4 роки тому

    Thanks for clarifying.

  • @Trauma_Clown
    @Trauma_Clown 4 місяці тому

    I need a video that of explaining who these Bob and Sally are, you're using them everywhere :3
    Im curious af for real

  • @xxxxxx3352
    @xxxxxx3352 5 років тому

    Hey man, can you please make a video on Observables, and what is the difference between it and Promises.
    Thanks.

    • @WebDevSimplified
      @WebDevSimplified  5 років тому +1

      Observables are a very specific concept with RxJS which I do not plan to cover since it will only be applicable to a narrow group of people.

  • @ihaseeb_khan
    @ihaseeb_khan 4 роки тому

    Thank you bro, really helpful :)

  • @monireachtang712
    @monireachtang712 3 роки тому

    very clear explanation! you are awesome!

  • @vikumravinayake1882
    @vikumravinayake1882 3 роки тому

    Problem solved
    Thank you very much. Ur a good explainer....

  • @placeholder_name321
    @placeholder_name321 3 роки тому

    so so simple. Finally.

  • @FredRosa
    @FredRosa 3 роки тому

    Great tutorial, thanks!

  • @kamalsyed4237
    @kamalsyed4237 4 роки тому

    loved it! Thanks.. Const, Let, Var .. it is :)

  • @hoakeen
    @hoakeen 2 роки тому

    Awesome tutorials! Thank you!

  • @jankiramulu
    @jankiramulu 2 роки тому

    Wonderful explanation.. Than you....

  • @ruslankovalov8292
    @ruslankovalov8292 3 роки тому

    Thanks God we have you to explain this!! thanks!! A lot! A mean that)

  • @jimilittle
    @jimilittle 3 роки тому

    That was awesome. Thank you

  • @halofreak644
    @halofreak644 3 роки тому +1

    You the real MVP

  • @ЕдвардГригорян-н6к

    great explanation. TY!

  • @upcom1ng116
    @upcom1ng116 3 роки тому

    For those who get an error "SyntaxError: Identifier 'letVariable' has already been declared"
    Look for another video "var, let and const for beginners (ES6)"

  • @SumitSinghrao
    @SumitSinghrao 3 роки тому

    Could you also explain if we declare a variable without var, let and const? Could you also make video on 'this' keyword.

  • @agaming7888
    @agaming7888 2 роки тому

    thanks for this now i know what to do 👍👍👍👍

  • @Thecanadiangamer25
    @Thecanadiangamer25 3 роки тому +4

    I get it..so let and const are your "idiotproof" code while var is...var kinda like the cooler cousin that your parents tell you to stay away from.

  • @shresthsrivastava27
    @shresthsrivastava27 3 роки тому

    Awesome explanation !

  • @mayorb37
    @mayorb37 Рік тому

    You make a wonderful work 👍👍👍👍👍 thanks

  • @andyarellano7474
    @andyarellano7474 2 роки тому

    Thank you so much bro.

  • @kushagraraj3163
    @kushagraraj3163 Рік тому

    you r jordi of webdev !!!!!!!

  • @andreastewart6133
    @andreastewart6133 2 роки тому

    Helpful. Thank you.

  • @andreas-wismann
    @andreas-wismann 2 роки тому

    Great! Suggested topic while you're at it: Semicolons in JS - use or omit?

  • @samv9425
    @samv9425 6 років тому

    If you had to make a dynamic clickable 2d grid , what would your approach be? Nothing code specific but what approach with either javascript / html or jquery would net you a result? I've tried making a table of tr and td with onclick=function but that's just messy imo.

    • @WebDevSimplified
      @WebDevSimplified  6 років тому +4

      I would use css grid to define the grid and then give all the grid items a class where I use addEventHandler to add an event to all those grid items for click. Here is a video tutorial I did for grid.
      ua-cam.com/video/9zBsdzdE4sM/v-deo.html

    • @samv9425
      @samv9425 6 років тому

      @@WebDevSimplified I'm gonna make this work for me, thank you so much you're a saint.

  • @sebnargeurbrok1374
    @sebnargeurbrok1374 4 роки тому

    well explained, thanks!

  • @robertoriosmorales7528
    @robertoriosmorales7528 2 роки тому

    awesome explanation

  • @mirzashowvik564
    @mirzashowvik564 Рік тому

    Great video !!!
    Love it

  • @RakeshBitling
    @RakeshBitling 3 роки тому +1

    can you please cover topic related to redis cache along with aws

  • @hanntongfong1226
    @hanntongfong1226 3 роки тому

    Great work! 👍