Abu Bakor Siddik
3 min readMay 7, 2021

--

Some JavaScript Knowledge we should know for being a good developer

#Error Handling:

Sometimes our scripts can have some errors. If a program has errors in any particular line or anywhere in the program, it can be stopped for code. But if we use Error Handler, for this particular error line, the program will not be stopped. That’s why we mainly use the Error Handler in our code.

But there’s a syntax construct try…catch,finally,throw that allows us to “catch” errors so the script can, instead of dying, do something more reasonable.

try {

Block of code to try

}

catch(err) {

Block of code to handle errors

}

finally {

Block of code to be executed regardless of the try / catch result

}

#Try Syntax : In try block where the error can be arise. Because the main code is being stored here

#Catch Syntax: catch block is a function. The main task of each block is handling the error if it arises in the try block. Otherwise it will ignore the code

#Block-Level Function:

#Finally Syntax: In finally block the hole code will run if there is any error or not doesn’t matter.

#Cross Browser Testing:

Browser testing is a method of quality assurance for web applications across multiple browsers. That is to say, it ensures the quality of your website on different screens. It’s implemented to ensure a website’s functionality and design and includes testing a range of devices and operating systems being used in the market and customer base.S o it is nesseccery to enhance the usability and quality of an application

#Comment: There are two type of comment mainly we use in our code, Single line Comments and Multi-line Comments

comments in JavaScript are used to explain the code and make the program more readable for developers.

#Single line Comments: Mainly Single-line comments are used to comment a part of a line or a full line of code in JavaScript. You can use it for explaining the code what did you do in that particular code. It’s start with the symbol “//”

// JavaScript code

#Multi-line Comments: using Multi-line Comments has the same reason why we used the Single-line comments. Multi-line comment block starts with symbols: /*. And end the comment, use these symbols */ again in the end.

*/ JavaScript code*/

#Coding Standard: Coding standard is that thing we followed while coding some procedure or best practice. A programmer must follow coding standard while coding .

#Needs of coding standards is

>Code will be more readable and complex less. So the any one can understand the code easily

>Security concerns will be reduced. Bug fixing will be more easier

>Performance will be more improve , because it is easy to maintain the code

Function:

#Spread operation: By using spread operation we can push an array into another array from outside. It constructs a new array.

function num(x,y,z){

Return x+y+z;

}

Let num1 = [1,2,3]

console.log(num(…num1) // 6

#Arrow:

By using arrow functions, you can write concise one-liners with implicit return and finally forget about old-time hacks to solve the binding of the this keyword in JavaScript. Arrow functions also work great with array methods like map(). .We can work Arrow function in two ways 1. Single-line Arrow function 2. Multi-line arrow function.

  1. hello = () => “Hello World!”;
  2. hello = () => {

return “Hello World!”;

}

#Function with default parameter value:

It is needed when we make a function. But sometimes it needs user inputs or sometimes users can’t give any inputs, but we must print a default value.In that case we use default parameter value.

Function message(text=”Hello”){

console.log(`${text}`)

}

message(): //Hello

--

--