10 Javascript concepts you should know

Tarequl Islam
4 min readMay 6, 2021

1.Handling Error

If you didn’t get an error, that’s mean u copied someone’s solved code :P
by the other, you will also be getting an error from nowhere. You have to deal with errors. This is the solution,
Now actually, I'm talking about Try and Catch system for system and size your error... Here the code

try { alert(‘Start of try runs’); 
}
catch (err)
{ alert(‘Catch is ignored because there are no errors’);
}

Now I'm showing you the catch method

try {
alert(‘Start of try runs’);
alert(‘End of try (never reached)’);
} catch (err) {
alert(`Error has occurred!`);
}

2.Primitive Values

All we know Primitive values are String, Number, and the other staff. Primitive value has one common thing, which is They didn't affect code.

It's like you are in class 6 and someone gives you advice and says, don't play cricket all day, Do some study…
But you know it doesn't affect you :P
Here some Example:

conole.log(10); //output: Number
console.log(“Anatna Khalil”); //output: Ananta Khalil

3.Cross Browsing Testing

We are live in a Smart genre right now, there is a lot of variation of browsers, smart devices, smart tv, and other devices...

Some browsers didn't rum modern syntax of javascript, modern CSS style , so developers always try to fit the project or web application comfortable with every device and gadget every browser preset right now.

Here are some points:
. someone still using an older device and browser that modern JS and CSS doesn't support
. Modern TV has a new smart feature and another aspect ratio and

Because of the developer is not actually a user so they have thought of other perfective to design

4.Coding Style

we can write code easily, but how many of us maintain the coding style? There don’t have any must rules, but we have to maintain some which pro programmers maintain. Coding style is called the art of programming.

Syntex

Curly Braces

Line length

Indents

Nesting levels

Function placement

If we maintain theses this our code will be more precise and more readable for others.

5. Comments

Comments are basically used for code understanding. Developers use this thing too much for organizing code. It's like you write this line and hidden it for runtime. The developer sees this line but run time didn't

There is a different type of comments, like single line and multiline.
Here is an example:

//for single-line comment/* for
multiline
comments
*/

But the best practice is to comment and describe the function variables. And professional developers always maintain it.

/**
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 pow(x, n) { … }

6. Spread Operation

A spread operation called a three-dot ( … ). It's the new powerful feature of ES6. It works for an array and calls all indexes value.
Here some example:

let hello = (‘obaji’)
let index = […hello]
console.log(index)
Output [ ‘o’, ‘b’, ‘a’, ‘j’, ‘i’ ]

7. Expression

Javascript expression is a kind of valid state literals. Variables and expression that evaluates a single value. It means it expresses all of the equation inside code and this value may be a number or string or any kind of logical value

let number = 4;
let sub = 20–12;

8.TypeOf

When we focus deeply, values are not the same type. We can check this the type of operator

console.log(typeof(10));
console.log(typeof(‘King Khan’));
console.log(typeof({}));
//Output :
number
string
object

We can also find Js Array and object

9.Caching Web Application

Cache collection simple meaning is collecting data in a store, When we load a web application local store saved our password, email as cache, that's why we didn't do log in every time we enter the application.
It saves our time by collecting all the important data and fetch them we need.

This is something like API also, when we request data, This request is received by the server. The server checks for a local copy of the file requested. If the local resource exists, the server responds with its resource URI. The client grabs the cached content.

10. Block Scope

Block scope is an area within if, switch conditions or for loop and while loop.
The simple math is when you see{ second bracket}. Its a block sope

let number = 50
let number2 = “BDT”
function calculate(){“ if(!number2){
let number 2
let number 2 = number
return number2 ”
“ }else {
return number2
} “
}

#note: “both quotation section are block scope”

--

--