The Best Way to Declare Variables in JavaScript?

  Рет қаралды 3,992

dcode

dcode

Жыл бұрын

In today's video, I'll take you through 3 similar code examples in JavaScript, giving us 3 totally different outcomes. The intention of this exercise is to demonstrate the differences between const, let, and var in JavaScript.
Moral of the story: use 'const' and 'let' where possible 🙂
For your reference, check this out:
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

Пікірлер: 10
@It_guy613
@It_guy613 Жыл бұрын
Dcode you are the best! Everytime i get into a new topic in JS i ALWAYS look for your channel first to check if you have made a video about it, you are a life savior, thank you!
@edutainment9235
@edutainment9235 Жыл бұрын
I hope this gets the 1 million views it deserves! let and const are always explained in way (for me) that are overly complicated. While these concepts are some level of complex, your explanation was 😮😮😮 ❤ #thankYou3000
@smoothbeak
@smoothbeak Жыл бұрын
3/3, fun little experiment.
@angryman9333
@angryman9333 Жыл бұрын
I love ur content ❤
@karlstenator
@karlstenator Жыл бұрын
Myself being late to the JS game, tbh I never use var - and find myself leveraging both const and let through all my work. There's probably a random use case out there that exists for var, but I'm yet to find it.
@amoh96
@amoh96 Жыл бұрын
im new to channel your videos about js really cool !! keep it !! im learning Js i want to be really good any tips or advice ?
@skillfulmind960
@skillfulmind960 10 ай бұрын
awesome
@Gigusx
@Gigusx Жыл бұрын
Not really mind boggling but I guess it depends on how you learn. Scopes and hoisting were one of the first things I've learned when I started programming (which also was in Javascript), after the complete basics such as what's a variable, function, etc. of course. I've always used const and let exclusively and understood what's going on in the scopes, including the scopes that have var e.g. in some existing code. Whenever I see "var" used it's always a) old code, b) people who're learning and don't quite understand the concept, or c) people who've come from a different language and try to do things in Javascript the same way they would in the other language. The C group is actually very similar to when people learning a human language rely on translating things from their native language too much. Their grammar, word order, etc. is always off because they're basically relying on these fixed rules from their own language and try to replicate it word-for-word in the language they're learning (it never goes well).
@DK-pf2dg
@DK-pf2dg Жыл бұрын
I think we should forget that var exist, I haven't used it for years.
@dcode-software
@dcode-software Жыл бұрын
I see your point but unfortunately I still see it getting used very frequently
var, let and const - What, why and how - ES6 JavaScript Features
19:19
Fun Fun Function
Рет қаралды 179 М.
How to Declare Variables in Javascript
16:21
Coding in Public
Рет қаралды 2,8 М.
I wish I could change THIS fast! 🤣
00:33
America's Got Talent
Рет қаралды 127 МЛН
تجربة أغرب توصيلة شحن ضد القطع تماما
00:56
صدام العزي
Рет қаралды 32 МЛН
Is This the Most Useful JavaScript Method?
9:40
dcode
Рет қаралды 1 М.
The JavaScript Spread Operator  -  One Thing You DIDN'T KNOW!
9:20
James Q Quick
Рет қаралды 25 М.
Should I pass by const reference or by value?
10:45
The Cherno
Рет қаралды 99 М.
Looking Under the Hood of JavaScript
6:34
ThePrimeagen
Рет қаралды 179 М.
JavaScript Let vs Var vs Constant | Mosh
6:51
Programming with Mosh
Рет қаралды 281 М.
Javascript Variables & Data Types | Javascript Tutorial For Beginners
15:13
5 Ways to Create Arrays in JavaScript
11:43
dcode
Рет қаралды 1,1 М.
I Built My Own Date Formatter With JavaScript
16:02
dcode
Рет қаралды 622
I wish I could change THIS fast! 🤣
00:33
America's Got Talent
Рет қаралды 127 МЛН