DEV Community

mohandass
mohandass

Posted on

Discuss about the topics of 1.what is javascript 2.Comparison of data types in js 3.Different Between Primitive and Non-primitive

what is javascript

  • Javascript is the high level,interpreted language that sever is the One of the core technologies of the world wide web.

    • Used to create Interactive and dynamic content for websites. While HTML provides the Structure of a page and CSS handled the style.
  • Javascript can ,calculate,mainpulat,and validate data.

  • Javascript is an object-oriented programing(OOP)language.But it is unique because it is prototype based rather than class based like (java,c++).

  • JavaScript is both a scripting language and a programming language.While it originated as a lightweight scripting tool for web browsers, it has evolved into a full-fledged, high-level programming language used for complex applications across many platforms.

  • Javascript is provides The behavior what make things on the page move,react or update to Your click.

Comparison of data types in javascript

  • In javascript data types are broadly categorized into "primitive" and "non-primitive"(reference) types.The fundamental difference lies in how they are stored in memory and how they behave during assignment or modifying.

Primitive Data Types

  • Primitive data types are the built-in data types provide by a javascript.They represent single values and are not mutable. JavaScript supports the following primitive data types

  • string

  • number

  • boolean

  • null

  • undefined

  • bigInt

  • symbol

  1. String
  • The string data type is used to represent a sequence of characters that are surrounding by a single or double quotes

Example:"hello",'welcome'

2.Number

  • A number data type is used to integers and floating point numbers

Example:(10,5,25)

  1. Boolean
  • it's logical values either true or false
  1. null
  • The null is intentional absence any value
  1. undefined
  • The undefined is variables declared but assigned a value
  1. Bigint
  • It's used for very larger integer and number type

Example:(9007199254740991n)

  1. symbol
  • It's used for unique identifiers in object properties

Non-primitive data types

  • The non-primitive data types are complex data structure that can store collection of value or more complicate entities.

  • object

  • Array

  • Function

Object

  • The object is collect a key value pairs used to store data

  • It's used to curly bracket {}
    example:

Array

  • The array is used to multiple values in single container

  • It's use with square bracket []

Example:

Function

  • The function is used to reusable block of code designed to perform a task.

Example:

Different Between primitive and Non-primitive Data Types

Primitive data type:

*immutable their values can not be changed once created

  • It's mean the immutable is reassign the values dose not replace a memory in older one.Then create the new memory to stored the values
let i = 10;
i = 20;

Enter fullscreen mode Exit fullscreen mode

Storage

  • Stored the values directly in the stack

  • Every values stored the stack in line by line

  • FILO - first in last out

Comparison

  • compared by a actual value

Example:

Methods

  • Do not have any builtin methods but use the wrappers

Non-primitive Data Types

  • mutable The content can be changed or modified after creation

Storage: Stored by the heap

  • Dose not maintaining any order stored by the heap

Comparison

  • Compared by memory reference or address

Example:

REFERENCE :
https://www.w3schools.com/js/js_datatypes.asp

https://www.geeksforgeeks.org/javascript/primitive-and-non-primitive-data-types-in-javascript/

Top comments (0)