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

preview_player
Показать описание
💖 Support the show by becoming a Patreon

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:

Resources:

- Semicolons cannot save you! (Another funfunfunction video)

- ES6 JavaScript Features (Playlist of this series)

💛 Follow on Twitch
We record the show live Mondays 7 AM PT

💛 Fun Fun Forum

💛 mpj on Twitter

💛 CircleCI (Show sponsor)
Robust and sleek Docker-based Continuous Integration as a service. I used CircleCI prior to them becoming a sponsor and I love that their free tier is powerful enough for small personal projects, even if they are private. Use this link when you sign up to let them know you came from here:

💛 Quokka (Show sponsor)
Wonder how MPJ evaluates JavaScript inline his editor. Quokka is the answer - use this link when you buy to let them know you came from here:

💛 FUN FUN FUNCTION
Since 2015, Fun Fun Function (FFF) is one of the longest running weekly YouTube shows on programming 🏅 thanks to its consistency and quality reaching 200,000+ developers.

🤦‍♂️ The Failing Together concept is what makes FFF unique. Most coding content out there focus on step-by-step tutorials. We think tutorials are too far removed from what everyday development is like. Instead, FFF has created a completely new learning environment where we grow from failure, by solving problems while intensively interacting with a live audience.

Tutorials try to solve a problem. Failing Together makes you grow as a developer and coworker.

📹 Each show is recorded live on Twitch in a 2-hour livestream on Mondays. The host, assisted by the audience, is tasked to complete a programming challenge by an expert guest. Like in the real world, we often fail, and learn from it. This, of course, reflects what the audience identifies with, and is one of the most praised aspects of the show.

⏯ On Fridays, an edited version of the show is adapted for and published on YouTube.

Content Topics revolve around: JavaScript, Functional Programming, Software Architecture, Quality Processes, Developer Career and Health, Software Development, Project Management
Рекомендации по теме
Комментарии
Автор

You are the most friendly instructor in the world

webapplication
Автор

TIL: always use 'const'. If you *REALLY* need to change state, use 'let'. 'var' is dead.

Thanks! ;)

olegon_yt
Автор

Tip for the arm/hand pain: Do hand exercises! Do a YouTube search for 'gaming hand exercise' and you'll find what you need. Just do this every 30-60 minutes for a couple of minutes... you'll notice a world of difference!

Thank you for the video. As always, great content!

Chocoholic
Автор

Love your videos as always!
I had some arm pain after starting my desk job - mostly in the forearm, and a little tingling around the ring finger. My solution was to make sure my chair was high enough that my arms were 90 degrees with my keyboard, and get a stand for my laptop so I wasn't looking down at it. The source of the problem was actually tight muscles up around my shoulders and neck, which resulted in a nerve being pinched. A little ointment on my shoulder when I found it getting tight helped too. It took a couple months but did get back to normal.

Mikethealtarboy
Автор

I have to admit I failed to understand what is hoisted ... until now, many thanks for you. I really enjoyed your tutorial video. Thank you again!

zsoltoroszlany
Автор

Thank you so much for making these videos. I have learned so much and have been entertained with your jokes. Thank you Thank You Thank You.

mikeyscimeca
Автор

First off of course... thanks so much for your great videos! I really enjoy them. Programmers are getting this now but historically this was a condition that pianists got. This has been topic of conversation for pianists for since the first piano was built. Some of the advice is to have your arm parallel to the floor and to keep your wrist straight (so as to not cut off blood or restrict the nerves) an d to let the weight of your arm or hand coming down (ie gravity) is what provides the force to hit the keys not forcing the arm down. Lots of books on piano technique out there that all programmers should look at.

qwarlockz
Автор

Brilliant Video. The talk about mutable state will definately help me design my code better going forward.

SayuStrife
Автор

Another arm pain tip: In addition to posture and exercises, if you use a mouse, train your opposite hand so you can switch and give each hand/forearm a break. The first week of using the opposite hand was quite challenging for me. I became both physically and mentally tired quickly. But after the first week my accuracy and stamina was good enough for non-pixel perfect use.

adamkucharik
Автор

Good stuff. Immutability is really key to taking advantages of higher level programming languages that can parallel process your code without explicitly defining how the parallel processing occurs. This is why functional programming languages such as Scala, Clojure, etc. are gaining traction.

I've been using JavaScript for 20 years and several of your JavaScript-centric episodes teach me something new about how things work "under the hood". Thanks mpj.

atxaqualion
Автор

impressive... very smart, no keyboard strok sound, no nasty backgroud sounds, theroy plus practical, deep knowledge so deep explaination ....amazing video !

ahwaliazizi
Автор

Hey just wanted to say thanks. I am a 3 years into Java development, was trained in one of the software development bootcamps and learned ruby. As JavaScript is taking over the world my knowledge about it was very basic, and your tutorials makes me interested to apply more of these principles. I do find your videos very engaging, very informative, clear and concise. Thank you.

afitnessca
Автор

I have learned two universal principles so far: minimize scope and don't reassign a variable. Well done with this episode!

vacprokop
Автор

I'm not even a JS programmer, but your show is so well done I look forward to it and watch it every week! Thank you!

stevenwilson
Автор

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!

ujleflc
Автор

I trained my left hand to be as efficient as my right hand using the mouse. It was annoying for the first week or two but you will appreciate being able too switch back and forth when one gets too painful. Its always good to have a backup.
Thanks for the awesome vid's by the way!

davidbrewitz
Автор

Thank you! I've been waited for next lesson about ES6 features and now I have it!

erickvoodoo
Автор

I had bad wrist pains from long days at the computer. I cured it by adding dumbbell wrist curls and reverse wrist curls to my workouts. 4 sets of 12 reps with light weights, 3 times a week. I also use gel keyboard and mouse wrist rests to try to keep my wrists in the same plane as my forearm. I’ve been wrist pain free for several years. Now would be a good time to also add some preventive shoulder exercises because that is another very bad consequence of too much desk work.

rdagger
Автор

"It's so nice for something to be immutable." Great explanation. I loved the dishwasher analogy. Thank you!

jamesmcginn
Автор

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.

patrickbarnes