Few More Random Topic related to js or not!

Faysal Islam Shuvo
3 min readMay 6, 2021
Photo by Mike Dorner on Unsplash

It has nothing to do with a banana! I dunno what to put here so I just search ‘random’ this nice-looking banana shows up!

“try…catch” error handling

we are not superhuman or supercomputer. so makes error all the time.

and this error occurs intentionally or most of the time unintentionally. Usually, an error occurs and we don't know about it. We don't know why it happened.

but there is something to catch the error. this is called “try…catch” syntax:

try {   // code... } catch (err) {    // error handling  }

how is it work?

first, the try code runs. and if there is no error then the catch is ignored and the rest of the code runs. but if an error happens the catch (err) watches it and tells us what wrong happened!

Arrow function

Arrow Function is an alternative of a function.

arrow = sh => sh + 10;

this is an example of an arrow function, where the arrow is the name of the function and sh is the parameter of this which returns sh + 10.

you can also declare an unnamed arrow function. such as

()=> 2 + 2;

The Spread Operator(…)

the spread operator is a new addition to ES6. what it does takes an array to expand its elements. it can also be used to add elements to an array. if you want to add one or more elements in the middle of an array the easy way is to use the spread operator.

let oldArray = ['i','am','Shuvo'];
let Array01 = ['faysal'];
let newArray = ['i','am',...Array001,'Shuvo'];

so what will be the new array you asked for? it will be

['i','am','faysal','Shuvo'];

Coding Style

There are no stone-cold rules of coding. If you follow these rules it makes your code more readable to others. So few of them down below

  1. Use a semicolon at the end of the line
  2. Give an empty line between logical blocks
  3. A space after for/if/while….
  4. Give a space between parameters, arguments.
  5. Don't make lines very long

again these rules are not must-have but it makes code easier. there are many rules to make your code readable nice and clean I will put a link below.

Block Statement

A block statement is used to group one or more statements. and for making block statements we use curly brackets {}.

{
one or more statement
}

Block-Level Functions

In ES3 and earlier, the function declaring inside a block was a syntax error. but the browser supported it. So, in ES6 the block level function allows and the block-level function is hoisted to the global environment.

Event Loop

after reading a few of the articles on event loop I still do know what it is but. i know what event loop does it monitor call stack and callback queue.

when the call stack is empty event loop will take one (first one) event from the queue and push it to the call stack!

Caching in Web Application Development

Caching is in simple way data collections. It is a mechanism by which accessed data will be stored. Efficiency is improved by storing data. There is many types of caching client caching, server caching.

Cross-browser testing

all the people do not use only one browser to surf the internet. there are many browsers out there. Firefox, Chrome, Edge, Safari are a few of the popular browsers out there. but there are more.

cross-browser testing happens so that website works as intended when using a different browser.

Hoisting

Hoisting is a JavaScript mechanism. by hoisting variables and functions move to the top of their scope.

That means no matter where are the functions and variables declared they are moved to of their scope.

--

--