Can someone explain the difference like I'm five? Thanks!
For further actions, you may consider blocking this person and/or reporting abuse
Can someone explain the difference like I'm five? Thanks!
For further actions, you may consider blocking this person and/or reporting abuse
David John -
David John -
WebAsha Technolohgies -
WebAsha Technolohgies -
Once suspended, carl_chambers will not be able to comment or publish posts until their suspension is removed.
Once unsuspended, carl_chambers will be able to comment and publish posts again.
Once unpublished, all posts by carl_chambers will become hidden and only accessible to themselves.
If carl_chambers is not suspended, they can still re-publish their posts from their dashboard.
Once unpublished, this post will become invisible to the public and only accessible to Carl.
They can still re-publish the post if they are not suspended.
Thanks for keeping CodeNewbie Community 🌱 safe. Here is what you can do to flag carl_chambers:
Unflagging carl_chambers will restore default visibility to their posts.
Top comments (5)
So when it comes to describing things like this, I like to try and make it analogous as possible.
Lets pretend that you have a treasure chest, and it's made with reinforced fiberglass. You know, really thick stuff so it's impossible to break easy with a rock! This treasure chest has no lock, and once you've put something inside of there and close it, it's in there forever. You can't change what's inside of it, but you can always look at it and see what it contains.
This treasure chest would represent const.
Lets pretend that you have a treasure chest designed exactly like the const one! Its only difference is it has a lock on it, and you have the key on you at all times! You, as pirate that controls all the way treasure is distributed on an island and to others, have complete control of the chest, what's in it, and what kind of things can go inside of it! Not only can you put whatever you want in there, but you can even decide it holds gold instead of gems, just by unlocking it and switching out its contents.
This treasure chest would represent let.
Now on to the more technical examples applied with the above analogies.
const String = 'yoooo'
String is 'yoooo' and cannot be anything but 'yoooo'
String = 'duuuuude'
String is already assigned and can't be reassigned! Same if you try to throw const in front of string
let String = 'yoooo'
Though you named it String, and makes it kind of silly to do so, lets "let" String be something else!
String = 8655309
String is now instead a totally random and not a two toned sequence of integers.
This is a very basic idea of these two things, but I hope it helps!
To add on to the great explanation by @coderjoe82 , you need to be mindful of the case where you assign an object as a
const
, sayYou can reassign the name property in this object with no problems.
But if you reassign a different instance then it will throw an error
Yes to this!
I was trying to keep it basic so as not to confuse, because speaking in a newcomer terms, saying "You can't change WHAT type of value const has, if you have an array or object, you can change what's IN the type of value that it has" can be a little mind blowing until you're more comfortable, hah!
let
is like writing your name with a pencil or washable marker; it can be changed or erased later.const
is like writing it in permanent marker. Once you write it it has to stay the same forever.Some comments may only be visible to logged-in visitors. Sign in to view all comments.