Data Types

Before going to start learning JavaScript you have to start from the basics. Many of them are directly going to the main topics and faced many stragles to learn any framework or Libraries after JavaScript. So here we will explain you about the Data Types which are available in JavaScript. Because in Interview you will be asked this kind of questions.

In JavaScript there are 2 different data types are there,

  • Primitive Data Types
  • Reference Data Types

Primitive Data Types

When you create any js code you may need to store any value in a variable, inside that variable you can store any kind of data like objects, array or other data types. There are some important data types are available that be asked in interview of JavaScript or React, Angular or any other framework jobs. Because without JavaScript those frameworks will not work.

In JavaScript there are 7 types of primitive types, they are

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

String

The string is just the characters whichever you typed in the scripts. It can be number or alphabets. Everything which are inside the single, double quotes or backticks are considers as strings. Most you will use any quotes while writing a string in your scripts. But in sometimes you may need to use single quote in your sentence, in that time you can combine both quotes.

Backticks: This is another useful method to write strings inside your code, sometimes you may need to insert dynamics values which are stored in different variables

Number

In most programming language you might hear Int or float for numbers. In JavaScript both integer and float values are Number type only. You can check the data type using some method which built in JavaScript they will see that later because that are advanced topics for beginners.

Int: numbers which does not contains decimal points.
Float: number which has decimal points

Boolean

Boolean is very important data type which you may need to use in many places. In many conditions you might face some situation like yes or no. In programming we called that True or False, you may know logical operators already. If not don’t worry you will learn everything from here. Mostly this will be useful in If conditions or Ternary operators.

Null

Null is nothing inside a variable, it means it is not number, string, Boolean or any other data types it’s like a empty place. Mostly this will be used at the initial stage and later may be changed the values for some reasons.

Undefined

Usually, we will define some values in the Let, Const or var, but in sometimes you may just create a variable and did not store any data in that variable. But you can't create a variable without data in const that you may already know. Basically, whichever the variable which was not defined that is called undefined type.

We can manually set a variable to undefined but it is not recommended way to store a data in a variable.

Symbol

Symbol type was introduced in ES6 (ECMA Script 2015). mostly for beginners you may not use this. Also, in interviews also many of the companies not asking about symbol but if you will be asked the data types. That time if you explain about symbols your profile may get shortlisted because of basic JavaScript knowledge were strong. Symbol is is built in object which returns a unique symbol.

BigInt

This is used to store very big integer number, but mostly you will no need to use this much big numbers in your projects.

Post a Comment

أحدث أقدم