JavaScript Keywords and Variables Definition - Explained For Newbies

JavaScript Keywords and Variables Definition - Explained For Newbies

Beginner's Guide to Programming

ยท

2 min read

Welcome to this beginner's guide.

In this post, I'll be explaining:

Meaning of "keyword" in Programming

Meaning of variables

What declaring a variable means

Naming a variable

Difference between declaring and naming a variable

Let's go. ๐Ÿš€

Keywords

In programming terms, keywords are reserved words.

images (57).jpeg Image source: wikitechy.com

"Reserved words" implies that you can't use those words wherever you want. They are reserved for special use and you can't use them for variables names or function names.

Click here for more information and examples about keywords in other programming languages.

Meaning of variables

In programming, variables are simply container for storing data. We use variables to hold values.

For example, var paint = red

Above here, "paint" is the variable storing a data "red". You are assigning red to paint.

images (59).jpeg Image source: article1000.com

Declaring a variable

When you declare variables, you are telling the program that you want to set a variable to use in the future.

For example, var paint = red

In this example, paint as a variable is declared with the "var" keyword. "var" in JavaScript is a keyword for declaring a variable and it is case sensitive, this, "Var" is not seen as "var".

Naming a variable

This is easy, every declared variable can be intialised by giving it a name.

To make it easier, see a variable as a bucket, the bucket stores red paint and the label of the bucket is the variable name.

Paint_Bucket.png Image source: roblox.fandom.com

So in the example var paint = red "paint" is the variable name.

Difference between declaring and naming a variable

To explain this, declaring a variable is like buying a bucket, naming a variable is like putting a label on the bucket.

As explained earlier, declaring variable is to tell the program that you want to set a variable to use in the future and this creates the variable space in the program memory.

Hopefully you'll find this blog helpful as you learn to code more effectively, and to know there's a lot more to learning to code than just the begining.

If you enjoyed this article and want to more content related to JavaScript and web development resources then follow me here and on Twitter at twitter.com/iamsegunajibola.

The end