JavaScript Basics

Dulya Kemali Perera
SLIIT Women In FOSS Community
3 min readMar 21, 2021


Here, I am going to note down the JavaScript basics since most famous technologies consist of JavaScript. So better to know the basics which are common to every technology.

Variables in JS

The previous version of JavaScript can be only used the var keyword to store data globally. But later, they are introduced two keywords let and const to solve the problem.

The main difference between const and let is const can not change its value after declaration while let can do. But let is a local variable, means can not use its value outside of the function if it is declared inside of the function.

Functions in JS

There is two way to define a function.

Regular Function and Arrow Function

An arrow function is pretty handy to use and makes the code more readable and easy to maintain as it gets longer with time.

Simple steps to follow up to use the arrow function:

  1. Remove the ‘function’ keyword.
  2. Then add the ‘=>’ after ().

Still, both can use the parentheses to pass parameters and if you have one parameter just omit the parentheses.


If you are writing a function as follows, the way you are called it is a little bit differ from as usual.

Here I use a function inside of the function. The reason to use the function inside a function is to access both local and global variable.

So that we can not get the value as a variable. So you can declare a variable that holds a function and call that variable as a function.

Destructing Method for Objects

Hope all know what is an object. If not here is the object.

The person is the object name. And the name, age, occupation are properties of an object. Usually, we call them key and value.

It seems like a JSON. But the object is not exactly to same as that.

And we can access those properties like this:

If have a big amount of variables to declare we use destruct method.

For example:

And if you want to put the name into a new variable called developerName, here you can do it.

So these the basics that you want to know before starts to learn JavaScript related technology.



Dulya Kemali Perera
SLIIT Women In FOSS Community

Developer 💻 | SE Graduate 🎓 | Writer ✍ | Passionate STEM Engineer since 2019 👩‍🎓 Geek since ever 👾