Some Important Features of JavaScript.

MH HABIB
3 min readMay 6, 2021

(1) Primitive Values in JavaScript

In JavaScript, Primitive values are the data that are not an object and nor any function. Primitive values are numbers and strings only. There is no opportunity to affect the primitive values in a code. Programmers can only use primitive values to customize their code on the basis of requirements. There are 7 types of primitive values in JavaScript. They are number, string, boolean, Bigint, null, undefined, symbol.

(2) Objects and Functions

Object and functions are called reference values in JavaScript. Objects and functions are also values, but these values are not primitive. Programmer can modify their code and can change their objects and functions as their requirements. Objects are used to create various key-based collections and more complex entities.

(3) Checking a Type

In JavaScript, we can check the type of any value using typeof() function. All values in JavaScript might look the same. But if we see closely we can identify the difference between the types of values. To identify this difference, and to identify data type JavaScript use typeof() function. We can check the data type as follow,

console.log( typeof(5) );

OutPut: “number”

console.log( typeof(“word”) );

Output: “string”

console.log( typeof(null) );

Output: “null”

(4) Comments

In any programming language sometimes programmers needed to write some hints or descriptions for further maintenance of their code. Using this hint they can easily understand the code. It’s also helpful to understand the code for a new programmer who was not associated with it previously. Single line comment starts with//, and multiline comment is written inside /* comment lines*/. For example,

Single line comment:

//Comment line1

Multi line Comment:

/*Comment line1

Comment line2

Comment line3 */

(5) Caching

In API communication caching is an important thing to handle data transmission between the client and the server. For better service, we need to ensure this communication path clear. Caching is a communication concept that provides efficiency by data availability. This mechanism is accomplished by storing the data in several places and serving the data from a common data store when requesting anyone from any place. This is strongly opposed to generating any new content for each time it is requested.

(6) Cross-browser testing

For a web developer cross base testing is very important to check the efficiency of any web application. It ensures that the website or the web application is acceptable for a number of web browsers or not. It needs to be acceptable for a number of web browsers. Because people can try the app or website by different browsers.

(7) Hoisting

Hoisting is a JavaScript mechanism where variables and functions are moved to the top of their scope before the execution of the code. If the variable is declared using the keyword var outside of the function then it moves to the top of the program and set as undefined as a global variable before the execution of the code. Then it needs to initialize the value of the variable.

(8) Block Bindings

The hoisting nature of variables declared by the keyword var it can be created problems or issues in some of the cases because of the accessibility of the variable. To rectify this issue it is important to declare the variable inside a block. For this reason, it is best practice to declare a variable using the keyword let instead of var. In ES6 development it is recommended to use let instead of var and use const for limiting the modification of the variable.

(9) Functions with Default Parameter Values

For efficient programming, we always need to declare different functions. The functions may have one or multiple parameters. When we call any function we need to the mansion the value of the parameters. If we mansion a default parameter value then it is easier to handle the function if the parameter’s value is not mentioned or undefined.

Here is an example to mention default parameter,

function add(a, b = 0) {

return a * b;

}

console.log(add(5, 5));

I this case output will be: 10

console.log(add(5));

I this case output will be: 5

(10) The Spread Operator

The spread operator syntax is (… Value). Spread operator is used to add some elements or values inside the existing array or objects. For example

let allNumbers = [0, 1, 2];

let newNumber = 12;

allNumbers = […allNumbers, newNumber];

console.log(allNumbers);

Output: [0, 1, 2, 12]

--

--