Why is assignment referred to as initialization? via /r/learnprogramming

Why is assignment referred to as initialization?

Frankly this is driving me nuts…the concept of initialization.


In JavaScript, when a variable is created it is initialized to a value of undefined.

What does it mean to initialize in computer programming?


initialization is the assignment of an initial value for a data object or variable. The manner in which initialization is performed depends on [the] programming language…

If I was to Google search initial value in computer programming I would find:


A default, in computer science, refers to the preexisting value of a user-configurable setting that is assigned to a software application, computer program or device.

Piecing everything together…when a variable is created it's assigned a default value (otherwise known as its initial value). JavaScript defines this default value as undefined.

function act() { var item; // undefined (it's initial value) } act(); 

However, now this is blowing my mind where I see this in JavaScript. How a variable is initialized with an expression (a primitive value for instance).

function act() { var item = 5; // initialization } act(); 

How in this instance above can a variable be initialized with an arbitrary value of an integer of 5?

I do some more reading in the Initialization page on Wikipedia (see above) and find:

In C/C99/C++, an initializer is an optional part of a declarator. It consists of the '=' character followed by an expression or a comma-separated list of expressions placed in curly brackets (braces).

Then I go on to think that any variable that has an initializer goes on to form the initial value of the variable. But how is that possible when my item variable has already been established with an initial value of undefined? Going by that logic item is being reassigned an integer of 5.

I'm just explaining my thought process here given so much content I read/ watch is phrased in a skewed way against my own personal interpretation. Clarification is very much appreciated. Thank you.

Submitted July 12, 2017 at 01:45AM by Ben_HH
via reddit http://ift.tt/2t2Ojjt


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s