Some Deep discussion of Javascript

Alamgir Hossain
3 min readMay 6, 2021

Primitive Values: There are seven kinds of primitive values. The most use primitive value is number, string and boolean. Primitive values do not affect by doing code.

(a)Number: Number used for mathematical calculation.

(b)String: String is used to saying something in text form.

© Boolean: Boolean is used for an argument (true and false)

(d) Undefined: Undefined is an empty value, when something does not defines this will output as undefined.

(e) Null: Null is also an empty value.

(f) Symbol: A symbol is a built-in object whose constructor returns a symbol primitive.

(g)BigInt:

Example:

conole.log(10) //numberconsole.log(“Alamgir”) //Stringconsole.log(null) //Null

Object & Function: Object and function also values but not primitive. Object and function values do affect by doing code.

(a)Object: Object is a collection of properties that store data as value.

Example:

var person = {firstName:”Alamgir”, lastName:”Hossain”, age:27};

(b)Function: Function is a procedure of output result after inputting any data. The function takes multiple parameters and it has a return statement. A function can call multiple times after defining it once.

Example:

function number(a, b, c, d) {///Execute code}

Event Loop: An event loop is a programming design pattern that works in the background and processes multiple works. The event loop creates a connection between callback Stack and callBack queue. Callback stack works by LIPO(last in first out), Callback queue works by FIFO(first in first out). It works to pass a value from the Callback queue to the Callback stack when the callback stack completes all synchronous functions.

Try… Catch: try, catch is a method of handling error. If something error in the code then it will execute a catch if there is no error then the catch will be ignored. If Catch does not define after try and if there have an error then hole code will crash. So it is important to use catch for handing error because when use catch and have an error in code then it will not crash but give result what error have a code. Try, catch work synchronously, it means if a function has setTimeout() function and if there have an error it will not catch the error. The build-in error has two main properties, one is a name and the other is a message. The name will give what type of error have and the message will show the text form of the full error.

Example:

try {// code…console.log(‘there is no error’)} catch (err) {console.log(err)}

Comment: Comment is used for details about how the code works. There are two types of comments. One is a good comment and the other is a bad comment.

Good Comment: Good comment is described very easily when the programmer thinks something will not understand by the user if that not mention. By good comments, a user can understand without looking back to code.

Example:

/*** Returns x raised to the n-th power.** @param {number} x The number to raise.* @param {number} n The power, must be a natural number.* @return {number} x raised to the n-th power.*/Function number(n) {}

Bad Comment: When a programmer explains what this code is, how it works, how to use and many explanatory things then it will call a bad comment.

Example:

// This code will do this thing (…) and that thing (…)// …and who knows what else…very;complex;code;

Arrow Function: Arrow function introduce in ES6. It allows defining function in a shorter format. If a function has one statement and returns a value then no need to return and {} bracket.

Example:

hello = () => “Hello World!”;hello = (str) => “Hello “ + str;

Function with Default Parameter Values: If a function is calling without a defined argument then it will result as undefined. If a function with default parameter value and not input any value when calling then it will show default value as result, and if give any value then that will show as result.

Example:

 function add(x, y = 2) {return x+y;}console.log(add(5)

The Spread Operator: The spread operator is used when all elements of an object or array need to include in a list.

Example:

function sum(a, b, c, d) {return a+b+c+d;}const numbers = [1,2,3,5,6];console.log(sum(…numbers));// expected output: 17

--

--

Alamgir Hossain

I'm a professional web- developer || JavaScript || React