Data Types In Node.js | CampCodes

Data Types in Node.js

May 30, 2020
node.js data types

Data types specify what kind of data can be stored and manipulated within a program.

There are six basic data types in JavaScript, which can be divide into three main categories: primitive (or primary), composite (or reference), and special data types. String, Number, and Boolean are primitive data types. Object, Array, and Function (which are all types of objects) are composite data types, whereas Undefined and Null are special data types.

Primitive data types can hold only one value at a time, whereas composite data types can hold collections of values and more complex entities.

  1. Initializing Data Types.
    var number = 1;
    let bool = true;
    const strng = "HELLO";
    let obj = {
        key: "object"
    var d = function datatype () {
        return true;
  2. Check the Data type of each variable.
    console.log("Must be number: ", typeof number);
    console.log("Must be boolean: ", typeof bool);
    console.log("Must be String: ", typeof strng);
    console.log("Must be Object: ", typeof obj);
    console.log("Must be function: ", datatype);
  3. Execute the program.
    1. Open Terminal
    2. Type: node datatype.js


data type in node.js

Please check out this Video Tutorial:

Leave a Reply

Your email address will not be published. Required fields are marked *