Brief Overview Of JavaScript For Absolute Beginners

Brief Overview Of JavaScript For Absolute Beginners

Introduction to JavaScript

ยท

6 min read

Being a Zuri intern I have made it mandatory to at least document most of what I learn there and share it with you all. The dev community is about helping others. Despite being a junior developer I still find it pleasurable to learn the basics over again.

I have been on JavaScript programming language for about 7 months now but yet I get to learn every day. Will I ever stop learning JavaScript? I doubt. Even if later on other programming languages fall in the way like that of PHP, C++ I will still end up going back to JavaScript to seek advanced knowledge in it. JavaScript is true "bae" ๐Ÿ˜!

Now, let's leave me and let's go straight to the business of this article.

What we will discuss:

  1. What Is JavaScript?
  2. JavaScript Syntax
    • Variables
    • Difference Between let and const
    • Rules for Naming Variables

JavaScript is one of the known languages developers use today. JavaScript leads โ€“ 5 million new developers since 2017. JavaScript remains by far the most popular programming language with developers, followed by Python and then Java, according to analyst firm SlashData's latest survey of developers.

What is JavaScript?

JavaScript, often abbreviated as JS, is a programming language that conforms to the ECMAScript specification. Javascript is a versatile language used for coding in multiple environments. Javascript can run on almost any machine. You can run javascript on the browser, you can run it on web servers, it also runs on smart devices, mobile phones (used for building mobile applications), it can also run on wearables, i.e. smartwatches etc.

Going back to my previous article on How To Get Started With Web Development I discussed JavaScript is a high-level programming language i.e It can either be translated using an interpreter or compiler. In this case, JavaScript is an interpreted language, it is interpreted by the browsers which have their own 'JavaScript Engines'. You could read more on that if you want to understand.

Let's go back to the simplicity of JS

Our focus for this lesson will be to understand JS basics and be able to read and write simple syntax.

Syntax

Syntax refers to the rules that define the structure of a language. Syntax in computer programming means the rules that control the structure of the symbols, punctuation, and words of a programming language. If the syntax of a language is not followed, the code will not be understood by a compiler or interpreter.

1. JavaScript Syntax

Variables

A variable is something that holds a value in memory.

For example:

let firstName = "John";
let lastName = "Doe";

The "let" word is called a keyword. This is what tells JS that you intend to create a variable. Asides from "let" there is "const". As the name implies it's gotten from the word "constant" which means something that cannot change.

Difference between let and const

  • Const statement cannot be reassigned and cannot be redeclared. For example:
    const x = 5;
    x = 10; // throws an error
    

Redeclaring will also not work:

const x = 10;
const x = 15; // this will fail

The words "firstName" and "lastName" respectively imply variables. The "=" implies an assignment operator. "John" and "Doe" are text strings. Strings are text, written within double or single quotes.

You might be wondering why I used "firstName" that way instead of "firstname".

Well, it should be noted that JavaScript is Case Sensitive. The variables firstName and firstname, are two different variables.

let firstName = "John";
let firstname = "Node"

In JavaScript, programmers name variables anyhow based on their preference though especially in joining two words together. Below shows the various way one can name a variable in JavaScript:

  • Pascal Case:
FirstName, LastName
  • Underscore:
first_name, last_name
  • Lower Camel Case:
firstName, lastName

Rules for Naming Variables

  • A name should start with a letter, an underscore
  • A name cannot start with a number
  • As said above, it is case sensitive.
  • JS reserved words like var, function, if, else and so on cannot be used as variable names.

Thanks for taking the time to read this article. I really appreciate it. You can do well to hit that LIKE button and share with your friends and family.

On this note, I say, Voila! ๐Ÿ‘‹