Book Top Rank with Contact Details visibility for your Business, Profession, Products or Services

Difference Between Variable and Constant in Javascript

Question by Saravana s On 26 August 2022, 20:55:12

(Page Views: 195)

Answer by Saravana s On 26 August 2022, 20:55:42

Why variables and constant

While developing any software application, we will be dealing with different types of data and data values. For example, if we are building a banking application then we need to maintain different types of data like customer name, account number if he or she has a loan, etc. Where customer name is a string type of data, the account number is an integer type of data, is he or she has a loan is a boolean type of data.

Another example, If we are building a game then we need to keep track of a variety of data like player name, player score, is game over, etc. Where a player is a string type of data, player score is an integer or number type of data and game over is a boolean type of data.

To store and process all such types of uses in memory, it is possible to locate and access some parts of a memory. It is possible to grab a chunk of memory and access it in the program or a script by providing a meaningful name to it. To allocate a memory location and provide a meaningful name to it, we use a variable or a constant. So, variables and constants are used to allocate memory locations and provide meaningful names to them. That we can be able to access them in a program by their name and we can store different types of values, and reuse them later in the program hasn’t been required.

Read more>>