10 JavaScript Topics That You Should Know — part 2

Roky Das
4 min readNov 3, 2020

Hello guys. I am Roky Das. I am here to share with you some important topics of JavaScript that you should know as a JavaScript developer. So, let’s start.

‘Try-Catch’ syntax:

When we make a software or app using any language, there can be a runtime error. Now I am simply talking about runtime error. When code is running well normally but for some special value, it may not respond well. It is called runtime error. To avoid this runtime error, we should use the ‘try-catch’ syntax. We have to put our that part of code in the ‘try’ block that may be the cause of runtime error. If there has been an error in the ‘try’ block, it prevents stopping our software or app. And it sends it to the ‘catch’ block. ‘catch’ block does something for running the app at the next level and also give a sorry message to the user for not running well.

try {
// code that can have problem
}
catch {
// code that can handle the problem created in 'try' block
}

Primitive & non primitive data type

There are many data types in JavaScript. But some of them are primitive data types and some of them are non-primitive data types. In primitive data, type variable contains straightforward value like a number, string, etc. But in non-primitive data type, a variable can contain some value that contains another value, or that type of value which directly cannot be printed out. They are objects, array, function, etc.

Coding Style

There are no rules strictly for coding. But you cannot be liberal in coding style. Because after your death or leaving company, another person will have to edit or maintain your source code. Or, you also may have to change your source code. If you need 1–2 days to understand the planning to make that software or app, then those 1–2 days are a losing period. So, when you coding first, you have to sincere that your code has readability to read for further use. So, you can follow some rules. But this is not fixed. You can customize them to your choice. But you have to ensure that your source code has readability.

Bad comments and Good comments

If you are thinking this is Facebook or Twitter comment, you are in the wrong place guys. You have to think like a developer. We maximum know about comments. We use comments to increase the readability of our source code. But extreme comments decrease the readability of our source code. So, we should know where to comment and where not.

When a function name is enough to mean it’s work, there is no need to make a comment using that function’s task. Sometimes, we add comments in the middle of a block of code. But we should not do that. We should comment at the starting of that block of code.

Cross Browser Testing

Cross-Browser testing is an important topic for all web developers. When we develop software or app, we use a browser to test at the time of development. We want to ensure that our software or app is running well in that browser. But all users will not use my favorite browser. They can use various browsers. So, we have to ensure that in every browser, our software or app should run well. That doesn’t mean that you have to test your browser in the world’s all browser. That’s not possible. But you have to find out your target users and the famous browser for them. Then you have to test in all these browsers.

Expression

We can ask ‘52 + 42 = ?’ to anyone. This can be answered by JavaScript also. If we add them to the console.log() function, JavaScript will answer it.

console.log(52 + 42); // 94

Like this, that question that I can ask JavaScript and JavaScript answer it, it is called Expression. We can ask anyone his/her name. But we can ask JavScript its name😂. So, it’s not an expression.

Arrow function:

It is a function that is mostly used in EcmaScript (ES6) that is an updated version of JavaScript. In the arrow function, we can take input in parentheses and make an arrow to describe the instructions that we want to execute.

const showName = (name) => {
// execute something
}

Object Destructuring:

It is described in ES6. In this method, we can easily get the value of properties of an object keeping the properties name same. See the example for the better understanding.

const person = {name: 'Roky Das', age: 22};const {name, age} = person;  // Object Destructuringconsole.log(name, age); // 'Roky Das', 22

Block-Level Declarations:

When we declare a variable for a block, then that variable is called block-level declaration.

const showName = () => {
const name = 'Roky Das';
}

Here, we declare the name variable in a block and it only can accessible in function showName.

Spread Operator

We use spread operator to get the all elements of an array or an objects.

const A = [4, 5, 6];
const B = [...a, 7, 8, 9];
console.log(B) // [4, 5, 6, 7, 8, 9]

here, B variable can get all elements of the A variable.

--

--

Roky Das

I am a self-taught programmer. I am now working as a Mobile App. Developer at Programming Hero. My core skill is MERN stack, Android (Kotlin), and Flutter.