The Best Way to Declare Variables in JavaScript?

  Рет қаралды 4,030

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.
@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.
@angryman9333
@angryman9333 Жыл бұрын
I love ur content ❤
@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).
@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 11 ай бұрын
awesome
@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
7 Powerful JavaScript Methods You NEED To Know
12:15
dcode
Рет қаралды 5 М.
The JavaScript Spread Operator  -  One Thing You DIDN'T KNOW!
9:20
James Q Quick
Рет қаралды 25 М.
Slow motion boy #shorts by Tsuriki Show
00:14
Tsuriki Show
Рет қаралды 8 МЛН
Каха заблудился в горах
00:57
К-Media
Рет қаралды 3,1 МЛН
Happy 4th of July 😂
00:12
Alyssa's Ways
Рет қаралды 70 МЛН
3+ Ways to Write Clean Code in JavaScript
13:33
dcode
Рет қаралды 9 М.
5 Real Life Examples of Array Reduce in JavaScript
12:47
Python Zip Function Explained in 1 Minute
1:21
TechMastery
Рет қаралды 1,2 М.
Maps vs. Objects in JavaScript - What's the Difference?
11:48
The Easiest Way to Export to CSV File in JavaScript
12:21
5 POWERFUL JavaScript Events You Didn't Know
10:43
dcode
Рет қаралды 15 М.
JavaScript Tutorial for Beginners: Learn JavaScript in 1 Hour
48:17
Programming with Mosh
Рет қаралды 12 МЛН
A const int is not a constant.
9:16
Jacob Sorber
Рет қаралды 66 М.
Slow motion boy #shorts by Tsuriki Show
00:14
Tsuriki Show
Рет қаралды 8 МЛН