Nodejs
Data Types in Node js
In Node.js, data types are essentially JavaScript data types since Node.js is built on the V8 JavaScript engine. These data types can be broadly classified into primitive and non-primitive types. Below is an overview of data types in Node.js:
Primitive Data Types
These are immutable and represent single values.
Number
Represents both integer and floating-point numbers.
var abc = 999;
var msg = 888;
console.log(abc+msg);
String
Represents a sequence of characters enclosed in single (
'), double ("),
or backticks (`).
var abc = "this is node js, having the modification";
console.log(abc);
Boolean
Represents true or false. let isNodeFun = true;
Undefined
A variable that has been declared but not initialized
let value; // undefined
Null
Represents the intentional absence of any object value.
let emptyValue = null;Non-Primitive (Complex) Data Types
These can store collections of values or more complex entities.
Object
Represents key-value pairs.
var abc = {
cname:"reactjs",
cdesc:"this is demo"
}
console.log(abc);
Array
Special type of object used to store ordered collections.
Special type of object used to store ordered collections.
var abc = ["this is react js",9999,"nodejs",8888];
console.log(abc);
Function
A callable object that can perform operations.
A callable object that can perform operations.
function abc(){
console.log("this is node js function");
}
abc();