NodeJS is a JavaScript framework, which uses the JavaScript syntax. To learn JavaScript in detail, you can refer to this JavaScript Tutorial. For now, I will quickly explain some of the basic NodeJS concepts, which are given below:-
Like any other programming language, NodeJS has various datatypes, which are categorized into Primitive and Non-Primitive datatypes.
Variables are the containers in the memory which holds the data value and it can be changed anytime. NodeJS variable can be declare by reserved keyword "var", "let", and "const".
var name = "Tutorials Logic";
An operators are used to perform a mathematical operation on single or multiple operands. NodeJS supports the below operators:-
Operator Type | Operators |
---|---|
Arithmetic | +, -, /, *, %, ++, -- |
Assignment | =, +=, -=, *=, /=, %= |
Conditional | =? |
Comparison | ==, ===, !=, !==, >, >=, <, <= |
Logical | &&, ||, ! |
Bitwise | &, |, ^, ~, <<, >>, >>> |
Function in NodeJS is a block of code, which is designed to perform any particular task. You need to use the keyword function to create it. A NodeJS function can be executed by calling or invoking it.
// Defining a NodeJS function
function sayHello() {
console.log("Hello World !");
};
// Calling a function
sayHello();