10 useful things on Javascript

Foysal Ahammed Sami
3 min readNov 3, 2020

--

Data types

Data type are very import in every programming languages. In JavaScript there are mainly two kinds of values one is Primitive values(Numbers and strings ) and another is Reference type(Objects and functions).Array is also a special kind of objects so they are reference type. Primitive type data are undefined, numbers, symbol, bigInt, boolean.
Reference type data are objects , arrays and functions.

Try Catch

To handle error we use try catch in JavaScript . The syntax is

try catch syntax

In try catch block compiler first try to execute the code of try block if it fails to execute the controls goes to the catch block . In catch block we have access to a argument called error . We can get the information about the error in error .

Variable declaration

Variable is like a container in JavaScript or programing in general and the name of the variable is the label of the container. We can declare a variable in in JavaScript in three ways using var, const and let.

Variable declaration

Arrow function

Arrow function is a new addition in ES6 JavaScript syntax. It is shorter and simpler . Here is an example

Promises

Promises are very useful for handling asynchronous action in JavaScript. Promises has three state

Pending ->When a promise is created.
Fulfilled -> Action performed successfully(then block will execute)
Rejected ->Action was unsuccessful (catch block will execute )

Here is an examples

Falsy Values

In JavaScript there are many values which considered as false while parsing by the JavaScript engine
They are undefined, null, NaN, “”(empty string), [](empty array), {}(empty object)

Comments

Commenting is necessary when we try to not execute a code or simply just want to say something about code but we don’t want them to run by the browser.

Comment example

Spread operator

In JavaScript ES6 we have a new operator called spread operator . This makes our life so much easier
Here is an example,

Parameter

Parameter is a special kind of variable that is used to pass information in function.

Here name is a parameter which is a variable for passing name .

Arguments

Argument is the value we passed in a function . Here Foysal is the argument of intro function and name is the parameter.

--

--

Foysal Ahammed Sami
Foysal Ahammed Sami

No responses yet