Let vs. Const in JavaScript - What's the Difference?
Vložit
- čas přidán 9. 05. 2021
- In today's video I'll be explaining the difference between let and const in JavaScript, how they work and when you should use one over the other.
Enjoy 😀
For your reference, check this out:
developer.mozilla.org/en-US/d...
developer.mozilla.org/en-US/d...
🏫 My Udemy Courses - www.udemy.com/user/domenic-co...
🎨 Download my VS Code theme - marketplace.visualstudio.com/...
💜 Join my Discord Server - / discord
🐦 Find me on Twitter - / dcodeyt
💸 Support me on Patreon - / dcode
📰 Follow me on DEV Community - dev.to/dcodeyt
📹 Join this channel to get access to perks - / @dcode-software
If this video helped you out and you'd like to see more, make sure to leave a like and subscribe to dcode!
#dcode #javascript
awesome, very updated and informational!
You’re simply awesome with your simplified explanation. Thanks for teaching us.
great simple and concise video.
Great stuff.
Dude thank you for making this video after watching this video, it really helped me understand!!
Can you make video for junior job JS with examples ? You have great videos and explanations :)
Great video! I was wondering if you had any tips for a small programming channel like myself? Thanks!
Thanks 😁 here's what I've learnt:
- viewers expect code to be left in the description (I do it much more often now)
- viewers expect dark mode
- try to have your code font size as large as possible but not too large that you can't scroll to the left and right
- keep consistent and don't give up because your videos aren't getting views. Some of my most popular videos didn't do that good for months
Good luck. I will subscribe
@@dcode-software Thank you for your advice I’ll make sure to incorporate it into my videos! Thank you for subscribing too!!
@@dcode-software I agree with every single point here, especially with large font size
Large font size is necessary while you're watching videos on reduced quality in Mobile data on a tiny screen
Also, I'd recommend adding closed captions/subtitles
@@nikhilmwarrier7948Will do!!
What about performance? Is there a benefit to using const instead of let?
Nah, nothing noticeable
Wait, can you modify an array/object declared with "const"?
I thought const declarations were immutable
Great video btw!
I personally like Rust's take on declaring variables though
In Rust, all variable declarations are immutable by default
Or you need the additional "mut" keyboard to _specifically_ make it immutable
It makes you think whether you will really need to mutate the value
I agree! The idea that you can change objects/arrays declared with "const" is the main reason why I made this video because I've seen "let" used so many times. With regards to constant by default, very true with Rust, and same goes for Kotlin 🙂
what's the difference with var and let though? why is let better than var?
var is old and have problems with reassigning values with different datatype and also block scoping problem, therefore not safe, that is why the jsWorkingGroup change it to use 'let'
'const' is harder to press in keypads than 'let', hahaha, extra two keypress, i hope in the future the jsGroup will change it to 'con' only, haha!
Lol yeah, but I just leave it to autocomplete...
c - o - _enter_
Three keypresses...
Best animation js library anime.js Vs gsap
Why not just use "let" all the time? The difference is that let can be reassigned, but what consequense does it have to use let and NOT assign it anything, versus having used const to do so? Seems like "Let" is just flexible when you need it to
The main thing in my eyes is that it helps better communicate your code. Put it this way, if you see "const" then you KNOW it will never be reassigned. Whereas you know "let" might be a computed variable.