Published on

Javascript and their data types .md file

Authors
  • avatar
    Name
    Ganesh Negi
    Twitter

JavaScript is a lightweight, high-level scripting language used to create interactive and dynamic web pages.

It enables the manipulation of HTML and CSS, allowing developers to insert dynamic content, handle events, and control the Document Object Model (DOM). As a client-side language.

JavaScript is essential for building responsive and engaging user interfaces in modern web development.

Data types

JavaScript have two types of data types:-

  1. Primitive
  2. Non-Primitive

Primitive data type:

The predefined data types defined by javascript are known as Primitive data type, it is also known as in-built data types.

Below following are the primitive data type:-

Numbers:

The Number type is a double-precision 64-bit binary format IEEE 754 value. The Number type has only one value with multiple representations: 0 is represented as both -0 and +0 (where 0 is an alias for +0).

Strings:

The String type represents textual data and is encoded as a sequence of 16-bit unsigned integer values representing UTF-16 code units. JavaScript strings are immutable. This means that once a string is created, it is not possible to modify it.

Boolean:

The Boolean type represents a logical entity and is represented by two values: true and false.

Boolean values are usually used for conditional operations, including ternary operators, if...else, while, etc.

Symbol:

A Symbol is a unique and immutable primitive value and may be used as the key of an Object property.

The purpose of symbols is to create unique property keys that are guaranteed not to clash with keys from other code.

Undefined:

undefined indicates the absence of a value, while null indicates the absence of an object

Null:

The Null type is inhabited by exactly one value: null.

Bigint:

The BigInt type is a numeric primitive in JavaScript that can represent integers with arbitrary magnitude.

BigInt values are neither always more precise nor always less precise than numbers, since BigInts cannot represent fractional numbers, but can represent big integers more accurately.

Non-Premitive data type:

The data types which are derived from primitive data types are known as non-primitive data types.

It is also known as derived or reference data types.

Below following are the non-primitive data type:-

Objects:

An object in Javascript is an entity having properties and methods. Everything is an object in javascript.

Functions:

A function in JavaScript is a block of reusable code designed to perform a specific task when called.

Arrays:

With the help of an array, we can store more than one element under a single name.

Code Blocks

Some Javascript code

var num1, num2, sum
num1 = prompt('Enter first number')
num2 = prompt('Enter second number')
sum = parseInt(num1) + parseInt(num2) // "+" means "add"
alert('Sum = ' + sum) // "+" means combine into a string

{
  "javascript": 1,
  "reactjs": 0,
  "nodejs": 0,
  "css": 0,
  "html5": 0,
  "nextjs": 0
}