Tutorialsteacher

Follow Us

Articles
  • C#
  • C# OOP
  • ASP.NET Core
  • ASP.NET MVC
  • LINQ
  • Inversion of Control (IoC)
  • Web API
  • JavaScript
  • TypeScript
  • jQuery
  • Angular 11
  • Node.js
  • D3.js
  • Sass
  • Python
  • Go lang
  • HTTPS (SSL)
  • Regex
  • SQL
  • SQL Server
  • PostgreSQL
  • MongoDB
  • JavaScript - Get Started
  • What is JavaScript
  • Setup JavaScript Dev Environment
  • HTML <script> Tag
  • JavaScript - Syntax
  • JavaScript - Popup Message
  • JavaScript - Variables
  • JavaScript - Operators
  • JavaScript - Data Types
  • JavaScript - String
  • JavaScript - Numbers
  • JavaScript - Boolean
  • JavaScript - Object
  • JavaScript - Date
  • JavaScript - Date Methods
  • JavaScript - Array
  • JavaScript - Array Methods
  • JavaScript - null and undefined
  • JavaScript - Function
  • JavaScript - if condition
  • JavaScript - switch
  • JavaScript - for loop
  • JavaScript - while loop
  • JavaScript - Scope
  • JavaScript - eval
  • JavaScript - Error Handling
  • JavaScript - strict mode
  • JavaScript - Hoisting
  • Define JS Class
  • JS Object In Depth
  • this Keyword
  • new Keyword
  • Prototype
  • Inheritance
  • Closure
  • IIFE
Entity Framework Extensions - Boost EF Core 9
  Bulk Insert
  Bulk Delete
  Bulk Update
  Bulk Merge

JavaScript Data Types

In JavaScript, you can assign different types of values (data) to a variable e.g. string, number, boolean, etc.

Example: A Variable with Different Types of Data
let myvariable = 1;  // numeric value

myvariable = 'one'; // string value

myvariable = true; // Boolean value
Try it

In the above example, different types of values are assigned to the same variable to demonstrate the loosely typed characteristics of JavaScript. Here, 1 is the number type, 'one' is the string type, and true is the boolean type.

JavaScript includes primitive and non-primitive data types as per the latest ECMAScript 5.1 specification.

Primitive Data Types

The primitive data types are the lowest level of the data value in JavaScript. The followings are primitive data types in JavaScript:

Data TypeDescription
StringString is a textual content wrapped inside ' ' or " " or ` ` (tick sign).

Example: 'Hello World!', "This is a string", etc.
NumberNumber is a numeric value.

Example:100, 4521983, etc.
BigIntBigInt is a numeric value in the arbitrary precision format.

Example: 453889879865131n, 200n, etc.
BooleanBoolean is a logical data type that has only two values, true or false.
NullA null value denotes an absense of value.

Example: let str = null;
Undefinedundefined is the default value of a variable that has not been assigned any value.

Example:In the variable declaration, var str;, there is no value assigned to str. So, the type of str can be check using typeof(str) which will return undefined.

Structural Data Types

The structural data types contain some kind of structure with primitive data.

Data TypeDescription
ObjectAn object holds multiple values in terms of properties and methods.

Example:
let person = { 
                firstName: "James", 
                lastName: "Bond", 
                age: 15
            }; 
DateThe Date object represents date & time including days, months, years, hours, minutes, seconds, and milliseconds.

Example: let today = new Date("25 July 2021");
ArrayAn array stores multiple values using special syntax.

Example: let nums = [1, 2, 3, 4];

Learn about each data type in detail in the next section.

TUTORIALSTEACHER.COM

TutorialsTeacher.com is your authoritative source for comprehensive technologies tutorials, tailored to guide you through mastering various web and other technologies through a step-by-step approach.

Our content helps you to learn technologies easily and quickly for learners of all levels. By accessing this platform, you acknowledge that you have reviewed and consented to abide by our Terms of Use and Privacy Policy, designed to safeguard your experience and privacy rights.

[email protected]

ABOUT USTERMS OF USEPRIVACY POLICY
copywrite-symbol

2024 TutorialsTeacher.com. (v 1.2) All Rights Reserved.