DEV Community

ViGnEsH
ViGnEsH

Posted on

JavaScrpit ->Data Types, Variables

2026 / April / 09

JavaScript

  • JavaScript (JS) is a programming language used in primarily for web development.
  • It is used to create dynamic feature for webpage and website.
  • It is store information used in variables and rules that guide how to used in interact with a program.
  • Also JavaScript is a Scripting Languages.
  • A JavaScript is a programming language designed to to automate excution.
  • Excuted in one by one or by line by interproter .
  • It is compline into machine code and we run a code.

Data Types

A JavaScript variable can hold 8 types of data, That are 7 is Primitive Data Types and 1 is non primitive Data type.

Primitive Data type

A JavaScript primitive data types define values for variables can hold, There are 7 is Primitive Data Types

  1. Number
    The are represent integer & floating both Ex:12 , 3.4

  2. String
    Single Quotes > 'Hello' / Double Quotes "Hello" / Backtick

`Total: ${price+
tax}`                (TBD)
Enter fullscreen mode Exit fullscreen mode
  1. Bigint
    Bigint is same number value also more than 10 value you can used.

  2. Boolean
    The are represent are one of two value ;true or flase

  3. Undefined
    JS Global propreties are undefined values , varible is declaed ans not intilized.

Example:

  1. Null Null is a used can't give value used for null

Example:

  1. Symbol This used to unique symbol like percentage,greater than and lessthan etc.

Non primitive Data type

  • Object Object is a non-primitive data types in javascript it used to multiple value store data,Created within {} or the new keyword. It is fundamertal as nevarly everything in Javascrpit in object.


  • Array An array is a non-primitive data types in javascript it used to multiple element under a single name. Created within [] Squard brakets or the new keyword. Ordered list value store in index numbers that start from 0.


  • Function Function is a non-primitive data types in javascript are also object. It can be assigned to variable, passed used argument to return for function.


Difference Between Primitive and Non Primitive Data Types:

Mutability:
Primitive data types are immutable, meaning their value once assigned can't change value create in new values
Non primitive data types are mutable and is can be change(modified values).

Storage:
Primitive data types are stored by value in stack (FILO) first in last out
Non Primitive data types are store by value in Heap their are refereances in value memory.

Comparison:
Primitive data types are compared by value
Non Primitive data types are compared in data address there is reference


Variables

Javascript variable are sympolic name used a containes to store data types
The are allow in information, such number or text write a code.
variable name _ undersore $ dollar sign allowed.

declared in 4 ways:

    1. automalically is a same variable name allowed in code
Enter fullscreen mode Exit fullscreen mode

     2. var is a same variable name allowed in code but it is used for function data types this function scope.
Enter fullscreen mode Exit fullscreen mode

     3. let provide block-level scoping, their are reassigind a value but redectarable not allowed
Enter fullscreen mode Exit fullscreen mode

reassigind

redectarable

       4. const provide block-level scoping, their are reassigind and redectarable both not allowed.
Enter fullscreen mode Exit fullscreen mode

reassigind and redectarable


referrenced : W3school, ideed, mdn, geeksofgeek...

Top comments (0)