Sitemap

Ten Basic JavaScript Topics

4 min readMay 6, 2021

--

Today I discuss about most commonly used JavaScript topics that helps all developers.

Press enter or click to view image in full size

01. Types of JavaScript

In JavaScript there are two categories of values. (a)Primitive values (b)Objects and Functions. There are nine types of values. They are — undefined (unintentionally missing values), null (intentionally missing values), boolean (logical operations — true and false), number (math calculations), string (for text), symbol (hide implementation details), bigInts (big numbers), Objects (group related data and code), functions (refer to code). We can check a values type using typeof(values).

Press enter or click to view image in full size

02. Try Catch Function

Basically, in try catch function there are two blocks. 1st one is try an 2nd one is catch. In first try block is executed, if there were no errors ignored the catch block. Other hand if something error occurred in try block stopped the execution and move to catch block also execute and display the error message. Let’s see an example.

Press enter or click to view image in full size

03. Comments

There are two types of comments in JavaScript. They are — single line comment and multi-line comment. In many times we comment out our code for future purpose. In single line comment use // and multi-line comment use starting point /* and end point */. You also comment out multi line using // but it’s not good practice and code looks not cleaner.

Press enter or click to view image in full size

04. Double and Triple equal

== check only variable value not type, other hand === check variable value also value type. Below example we check the condition using ===. First one is number type and second one is string type. Seems both are same number but different. So, condition return false.

Press enter or click to view image in full size

05. Function Declaration

Get samiul sheikh’s stories in your inbox

Join Medium for free to get updates from this writer.

In JavaScript function take one or more parameter. We pass value in parameter by calling function. Below example pass 5 in square function and the number will be multiplied by itself.

Press enter or click to view image in full size

06. Function with Default Parameter

In add function parameter we set default value in b. when call the function pass only one value 50 which take parameter a. then the function return calculation a and b.

Press enter or click to view image in full size

07. Spread Syntax

Spread syntax allow array or string or object placed where they need to be clone. Write spread syntax using (…)

Press enter or click to view image in full size

08. Arrow Function

JavaScript ES6 no need to write function before function name. in one line we can declare a function also return. If function need to more than one parameter use (). Let’s see an example.

Press enter or click to view image in full size

09. Block Scope

When a variable declared with var it does not have block scope. But when the variable declared with let or const it has fixed block scope. Cannot access outside of the scope.

Press enter or click to view image in full size

10. Reusable block of code

Anytime we handle an array for our need. Below an example.

Press enter or click to view image in full size

Thank you, see you another article….

--

--

samiul sheikh
samiul sheikh

Written by samiul sheikh

0 followers

Software Engineer