What are Data-Types in JavaScript?

    1. Data types always represents the type of information variable has.
    2. Every programming language have their own set of data-types.
    3. JavaScript also have several data-types but as programmer we usually don’t use them explicitly.
    4. JavaScript is loosely typed scripting language hence data-type declaration is not required it’ll be resolved internally.
    5. In case of TypeScript we need to declare data-types explicitly since its stricter version of JavaScript so it’s always better to understand data-types.

How Data-Types are classified in JavaScript?

    1. In JavaScript data-types are mainly classified into two types i.e. Primitive and Non-Primitive.
    2. Primitive Data-Types
      1. String
      2. Number
      3. BigInt
      4. Boolean
      5. Undefined
      6. Null
      7. Symbol
      8. Non-Primitive data-types
        1. Object
        2. Arrays
        3. Functions
        4. Dates
        5. Maps
        6. Sets
        7. RegExp

String

  1. In JavaScript String is used to re-present textual information same like other programming languages.
  2. JavaScript supports different types string declarations.
  3. E.g. “Hello”, ‘Hello’, `Hello`
let name = "John"; let city = 'Mumbai'; let message = `Hello ${name}`;
let name = "Akshay"; let age = 30; console.log(`My name is ${name} and I am ${age} years old.`);
Share.
Leave A Reply

Exit mobile version