10 important topics about JavaScript

devfaysalkhan
5 min readMay 6, 2021

--

Discuss areas are:

  1. Primitive VS non-primitive data
  2. Type of keyword for data
  3. try-catch error handling
  4. Var declaration & hoisting
  5. Block-level scoping with let and const
  6. Functions
  7. Block-level functions
  8. Arrow functions
  9. Spread operator
  10. javaScript comments

Today I will discuss 10 important things about the JavaScript programming language. So let’s go.

  1. primitive VS non-primitive data

JavaScript has different kinds of data. It has classified mainly two categories. They are primitive and non-primitive. The primitive data values mean that it is not an object and also has no method. There are five types of primitive data. They are string, number, boolean, null, undefined but average people say that Bigint is one kind of primitive data, and now symbol added to the list as primitive data types. Symbol data types called atoms in another programming language. Primitive data types are immutable.

Non-primitive data types are mutable and the examples of non-primitive data types object, RegExp, array but the date is also I think.

2. type of keyword

Before discussing the type of keyword we should know about data types of JavaScript programming language. There are six data types of Js language besides has also structural data types and structural root primitive data type.

If we want to check value types then remember the type of keyword. It is a useful keyword that helps to check what kind of data value you are used. Check this code chunk,

3. try-catch error handling

Every JavaScript developer should know about the try-catch error handling method. Sometimes occurred an error in code so handling errors we use try this. For example,

about this code chunk, the output will be no error alert message but if you have to write code alert instead of alert then the output will show an error. Advanced level use cases of try-catch are published soonly.

4. Var declaration & hoisting

The var keyword used to code as declare a variable. It is used function scope or global scope variable. It is an ES5 standard variable. In this example, I will describe how the var keyword use as a global variable scope.

var keyword use local and global

In this code, the z variable declares as the local scope and global scope with the var keyword. But according to ES6 standard let and const keywords not obey the rules. The var keyword process before any code is executed is called hoisting. Hoisted means keep value into a variable with the keyword.

5. Block-level scoping with let and const

let keyword in JavaScript is function scope. This keyword works only into the scope. For example, if, for loop, while loop, function created specific block. If we declare let variable into the scope, it has worked only into the scope it,s not work globally. Besides const is one kind of keyword that is used strictly because it is not redefined. let a variable to do redefine only into their specific scope and var worked globally that means works everywhere.

Besides const is one kind of keyword that is used strictly because it is not redefined. let a variable to do redefine only into their specific scope and var worked globally that means works everywhere.

6. function

A function is one kind of small chunk of code that helps to make specific work solutions. It is reusable so the Js developer can save time and make code standard by using the function strategy.

At first, we remember that function has declared in many ways so I will try to declare functions in many ways in other blogs. Now I will show the basic declare of function.

If we work with function then firstly write a function keyword then decare variable with first braces and after that curly braces. The curly braces area is called the scope of function. Then we call the function outside from the block. In the meantime declare two-parameter x and y and it is worked when declaring as an argument in call scope. Argument means the value of the parameter.

7. Block-level function

Just follow 4 and 5.

8. Arrow function

The arrow function is one kind of updated function. It is included ES6 standard JavaScript. Arrow functions allow us to write shorter function syntax. Arrow function is included in ES6. It returns value by default. The use case of arrow functions is given below through one example.

In this example, I used the arrow function to determine friends naming array data length. Every array data length is found in one time by arrow function. That means you statically or dynamically multiple data loads in one time by arrow functions.

9. Spread operator

It is so useful for every js developer because it helps to copy previous data values. Spread operator symbol identified by three dots. For function calls it helps to expanded places for one or more arguments and also expanded objects key-value pair element.

At first, I used the spread operator in town friends array to expand village friends array data into town friends. Then again spread operator applies to all friends array. Finally, show all kinds of friends by console log. Here I discussed only one use-case of spread operator into array literal.

10. javaScript comments

Comments are useful for any programming language coder. It makes more code redable and explain. Two ways to write to comment on code, single and multiline comments.

--

--

devfaysalkhan
devfaysalkhan

Written by devfaysalkhan

I am React and JavaScript Developer. I'm obsessed with solving complex problems using React, MongoDB, MS SQL, and Node.js by building web application.

No responses yet