Storing Values with the Assignment Operator vs Initializing Variables with the Assignment Operator

Tell us what’s happening:
What is the difference between “Storing Values with the Assignment Operator” and “Initializing Variables with the Assignment Operator”?

What is the difference between assignment and initialization? and what is initial value?

Your code so far


// Example
var ourVar = 19;

// Only change code below this line
var a = 9;

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.75 Safari/537.36.

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-javascript/initializing-variables-with-the-assignment-operator

Consider this:

var a; // That's how variable declared.
a = 9; // That's how you assign value to a previously declared variable

var b = 10; // You can do all the above in one line

In both cases you can tell that variable ‘stores’ a value (even though it’s not technically correct)

I’ve never heard the term ‘Initial value’ and ‘Initialization’ in the context of variables in JavaScript, I guest whoever wrote this just meant ‘value’ in general and ‘assignment’. That’s super weird to call assignment an initialization, maybe people used this term before, but definitely not now. Normally people use term initialization when they create a new object from a class.

Thanks for you reply

So you mean there’s no difference between this section: https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-javascript/initializing-variables-with-the-assignment-operator

and this section: https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-javascript/storing-values-with-the-assignment-operator

right?

Well, variables have different names, so there is some difference, but other then that, in both lessons you are just declaring variables and assigning some values to them.

2 Likes