JAVASCRIPT 101: INTRODUCTION TO MODERN JAVASCRIPT
Tags: beginners, javascript, webdev, programming
Published: 2022-02-20 11:33:57

# JAVASCRIPT 101: INTRODUCTION TO MODERN JAVASCRIPT

Yeah, I get it. You're done with multiple courses and a few static webpage projects on **HTML** and **CSS** and are really getting obsessed with this web development world. You're itching to learn **JavaScript**. Oh! Yeah, almost forgot you, among the few other hand, looking to get the hang of a programming language first; well you've all come to the right place. My subtle **Introduction to Modern JavaScript**. Your tour to this magical world of sensation.

JavaScript is no doubt one of the most important programming languages. It is probably the most sorted out because of its flexibility of use cases. From its use in **DOM manipulation**, **client-side** handlings to **back-end** functionalities. Nowadays, you even see some games with JavaScript.

So, why wait when we can start now.
    
## JAVASCRIPT OUTPUT 

Results of processes can be retrieved in a number of ways in JavaScript, specifically about 4 ways but each use case has their peculiarity. This article would focus on the most popular; '`console.log`' used to log output to the console. This can be assessed very easily without needing to download any **IDE** (*Integrated Development Environment*), as JavaScript can run in the browser itself. You can get access to the console in your browser from the developer tools menu of your browser. If you use chrome, the shortcut '`ctrl + shift + I`' will prompt your console. 

You can try out  `1 + 2` and hit enter on the console and you'd get `3` as a result. **Yeah! That's accessing the console directly**.

A more practical way would be  accessing it through a script from within a webpage, in which case you'd need the '`console.log`' statement.

## JAVASCRIPT VARIABLES
Just like in algebra where we assigned a letter, say `x` to a value that changes, Javascript also works with variables.
Variables in JavaScript can be *initialized* in about **3** ways using the following keywords;

* var
* let
* const

### var  
`var` is used for initializing  and assigning values that you want to be reusable anywhere within the code. It is usually *hoisted* and can be assigned before even initialized.

### let 
`let` functions almost like `var`, but has a scope limitation, so it is only operable within the curly brackets it's initialized. `let` variables are also hoisted like `var`, although they are not allowed to be assigned prequel to initialization.

### const
`const` are pretty much similar to constants in algebra, stuff like `Pi` that has an unchanging value. const values must be assigned immediately they're initialized like so;

``` Javascript
const num = 1; 
```

## JAVASCRIPT DATA TYPES

**Data Types** in JavaScript refers to the type of data a particular value is. I.e whether it's a number, string etc.. We have the following **primitive types**;

**Bool** - represents a boolean value i.e true or false.

**Number** - represents a number literal e.g 10, 11.098 etc.

**String** - represents a string literal i.e a strand of characters between a single or double quote. For example, *"I am a boy"*, *'She is Joy'*. 

## JAVASCRIPT OPERATORS
Operators operate on two or more operands (values) to give a result in an operation. Most of the basic arithmetic operators are supported in JavaScript e.g +, -, *. 

Comparison operators like **==** or **===** (equals), != or !===(not equals), etc.
You would like to note that **=** is not the same as equals in JavaScript like in math. In JavaScript it's used as an **assignment operator**, to give variables a particular value.

Logical operators like '&&' (and) and '||' (or) are also supported.

Yeah, that's it for the sneak peek. To get more insight into JavaScript you may want to use the [W3Schools JavaScript Tutorial](https://www.w3schools.com/js/default.asp "Javascript Tutorial").