What You Have To Know About JavaScript

Kazi Imam Hossain
2 min readNov 3, 2020

Data Types Concept

Data types are the most important thing in every programming language. So it is important to know about data types.

Data types are two types.

  1. Primitive Data Type
  2. Non-primitive Data Type

Primitive Data Type

There are six primitive data types in JavaScript. This are-

  1. String
  2. Number
  3. BigInt
  4. Boolean
  5. Undefined
  6. Symbol

There also is a null data type, which is seemingly primitive, but indeed is a special case for every Object and any structured type is derived from null by the Prototype Chain.

Non-primitive Data Type

There are three non-primitive data types in JavaScript. This are-

  1. Object
  2. Array
  3. Function

Error Handling

As human beings, none of us are above mistakes. When it comes to programming, we always make mistakes unknowingly. Many times it becomes difficult to find out these mistakes for us. There’s a tool called try…catch in JavaScript which can help us to find our errors. We can find out our errors easily using try…catch.

Here is the try-catch syntax:

The code inside the try block will execute. If there’s any error found then the catch block will execute. Otherwise, the catch block will be ignored.

Coding Style

Coding should be clean and clear as much as possible. Smart and standard coding style helped others to understand code easily. Beautifying is also the art of programming.

Here some rule for beautifying code-

  1. No space between function name and parentheses
  2. No space between parentheses and parameter
  3. Single space between parameters
  4. Curly braces “{” on the same line after a single space
  5. Indent code of blocks with 2 or 4 space
  6. A single space after for/if/while
  7. A single space around mathematical operators
  8. A semicolon “;” at line end
  9. An empty line between logical blocks
  10. Split every long horizontal line
  11. A single space around a nested call

Comments

Usually, comments are used to understand the code segment or function which are used for what reason. If we open a project code a long time later it's hard to understand the code. If the project was so big it’s impossible to understand. So, what's the solution? Comments. The programmer uses the comment in the code segment to understand which purpose the code used.

We can comment two different ways.

  1. Single Line Comment (Start with //)
  2. Multiline Comment (Lines are blocked with /*…*/)

--

--

Kazi Imam Hossain
0 Followers

A curious JavaScript Lover as well as MERN stack developer. I know React, NodeJS, ExpressJS, MongoDB and continue deep learning on these.