var, let and const – What, why and how – ES6 JavaScript Features




In ES5, we only had one type of variable, var, but in ES6, we have three. types of variables: var, let and const. In this video, we explore the what, why, and how of var, let and const, and I also do a little lecture on the value of minimising mutable state.

► 00:35 var keyword in JavaScript
► 02:35 Immediately-Invoked Function Expression (IIFE) in JavaScript
► 03:14 hoisting variables in JavaScript
► 08:29 let keyword in JavaScript
► 11:55 const keyword in JavaScript
► 14:14 Minimize mutable state when programming

I’m also active on:
– Twitter https://twitter.com/mpjme
– Medium https://medium.com/@mpjme
– Quora https://www.quora.com/profile/Mattias-Petter-Johansson

Resources:

– Semicolons cannot save you! (Another funfunfunction video)

– ES6 JavaScript Features (Playlist of this series)


Original source


20 responses to “var, let and const – What, why and how – ES6 JavaScript Features”

  1. This explanation is not that straight forward. It is concluded the issue LET solves is basically, just the closure overhead. I read variables declared with LET are not hoisted within a block and therefore an exception is thrown if used before declaration, so that's another benefit (because it forces you to code predictably), but are there any other benefits I might be missing here?

  2. Hey man, regarding your arm pain (RSI) have you tried using a magic trackpad 2? I find that it helps with hand ergonomics. I've just started using one myself 🙂 It just seems nicer because your fingers and hand can essentially remain flat and not curved over the traditional mouse. ( and i have many, many different types of mice! from magic mouse, to microsoft sculpt keyboard/mouse, razer, logitech gaming mice etc)

  3. Hee!

    I found out that Yoga works a lot for me. While I'm studying computer sciences accuires to sit around a lot the body is out of balance.I hope this helps, thanks for the great videos, keep them coming!

  4. When he is making video 20 minutes length, you know you will watch it for one hour, not because of looking to understand problems and various situations, , but looking his facial expresions, movement, voices and shouts and constantly repeting them. Yes.

  5. I also have problems with this type of pain. What I started doing is switching the mouse hand from time to time. At first it is REALLY hard to use it with the other hand (but I had no choice, was finnishing my masters and had to keep writting my dissertation and coding). But nowadays I can use both hands
    with the same speed.

    I also noticed that puting my chair higher helped.

    Good luck!

  6. Just discovered you today and can't stop watching. Great content and humor! Concerning arm pain: I had this and it was due to clicking on mouse buttons. Makes sense that extending a finger and mashing a button hundreds of times a day would cause RSI. Problem went away quickly and has stayed away for years when I replaced the mouse with, first, a Wacom tablet and later a magic track pad with tap to click enabled.

  7. Great video sir! in terms of ergonomics: i used to experience what you described on a daily basis previously.
    What fixed it for my was: Have a chair which has a good straight sit mode (not hanging back nor too forwards) and make sure that your chair has armrests where your elbow can rest at height of about 2/3cm lower than your desk height.
    Also what is essential is using a mouse that suits your hand. It would shock you to know how many people use too small mice.
    A nice long mouse ergonomics wise is the Razer Deathadder.

    Again thanks for making these awsome video's for new aspiring JS devs and i hope your arm is okay again by now!

  8. "15:20 fucked up some set of inputs some timing in some consolation made one variable be" …

    Where you said that "one variable got set before one other" and the program got fucked up, but same inputs and same expected outputs. Since it's not user error… is it then, the issue of the written JavaScript program, or is it the JavaScript interpreter that messed up?

Leave a Reply