Sitemap

Basic JavaScript Recap

2 min readNov 2, 2020

--

After learning JavaScript, we might forget some stuffs that are essential for our later journeys with this language. Lets begin recapping some of those important stuffs.

Var vs Let vs Const

There are 3 different variable declaration system in JavaScript : var, let and const. All these 3 are different.

Var is function scoped when it is declared within a function. This means that it is available and can be accessed only within that function. So when Var is declared outside a function its global.

A variable declared in a block with let is only available for use within that block. Let can be updated, but not re-declared. Let is generally preferred for variable declaration nowadays.

Variables declared with the const maintain constant values. Const declarations share some similarities with let declarations. But const variables can’t be updated. Also can’t be redeclared like let.

String Properties and Method

There are different kinds of string properties. Suppose, we have a situation where users have to sign-up and their credentials are going to be saved in DB. But we have to store them in DB as smaller case letters. But users might make uppercase or mixed case inputs. There are some string methods then which can make the input strings in desired letter case. So we gonna use string.toLowerCase() and it’s going to make it in lowercase. There are other important methods like concat, replace, charAt etc .

Array Methods

Different array methods have their different uses. We can push any item to an array like array.push(item). Also can pop an item from the end like array.pop(). Also there are methods for different purpose like array.shift(), array.unshift(), array.slice().

Regular JS Functions

Regular JavaScript functions are written like :

let addNumbers = function(a,b){

Get Iftekhar Priyo’s stories in your inbox

Join Medium for free to get updates from this writer.

return a+b

}

Arrow Functions

In ES6 the functions are written differently :

let addNumbers = (a,b) => a+b

In the above code in the bracket these are the parameters. And after the arrow, its the return value or statement.

Array Map Method

Array Mapping is the alternative to for loop. Suppose we have an array = [ 2,4,6,8 ] and we have to double all the elements in there. The mapping would be…

var newarray = array.map(myFunction)

function myFunction(num) {
return num * 2;
}

Closures

A closure is the combination of a function bundled together with references to its surrounding state. In other words, a closure gives you access to an outer function’s scope from an inner function. In JavaScript, closures are created every time a function is created, at function creation time.

Bonus : SSL

When installed on a web server, it activates the padlock and the https protocol and allows secure connections from a web server to a browser. Typically, SSL is used to secure credit card transactions, data transfer and logins, and more recently is becoming the norm when securing browsing of social media sites.

--

--