codeGK
Code it ALL
JavaScript Data Types - CodeGK
♦ JavaScript Data Types

♣ About JavaScript Data Types

Data Types are the type of entities which are in action.
JavaScript Data Types are majorly classified as Primitive Data Types and Complex Data Types.

♣ Primitive Data Types in JavaScript

Primitive Data Types are minorly classified as:-
  1. string
  2. number
  3. boolean
  4. undefined

♣ Example1: String in JavaScript

String data type is used to store textual data.
In this example, String data type is illustrated.
Example
Input:
Output:

♣ Example2: Number in JavaScript

Numbers data type is to store any real number.
In this example, Number data type is illustrate.
Example
Input:
Output:

♣ Example3: Boolean in JavaScript

Boolean data type used to store boolean variable, i.e, true or false.
It stores value true if the statement is true and stores false if the statement is false.
In this example, Boolean data type is illustrated.
Example
Input:
Output:

♣ Example4: Undefined in JavaScript

A Data Type is undefined when it is left only defined, and not initialized.
Let us see two scenarios below in the given example:-
Example
Input:
Output:

♣ Complex Data Types in JavaScript

Complex Data Types are minorly classified as:-
  • object
    1. object
    2. array
    3. null
  • function

    ♣ Example5: Object in JavaScript

    Object is a Data Type that can hold many other data types such as attributes, i.e, a custom data type can be defined.
    In this example, Object is illustrated.
    Example
    Input:
    Output:

    ♣ Example6: Array in JavaScript

    Array is a list of certain data type, i.e, number of variables are stacked in array data type.
    In this example, Array is illustrated.
    Example
    Input:
    Output:

    ♣ Example7: Null in JavaScript

    Null is a data type which contains no value, but still exists, because it can be modified if required by initializing initially to null if required.
    In this example, Null is illustrated.
    Example
    Input:
    Output:

    ♣ Example8: Function in JavaScript

    Function is set of comprehensive code which can be called on and on whenever required.
    In this example, Function is illustrated.
    Example
    Input:
    Output:
    Prev_LessonNext_Lesson