Modules in Nodejs in Hindi - Nodejs Modules in Hindi
इस Article में Modules in Nodejs in Hindi के बारे में पढ़ेंगे। जिसमे पढ़ेंगे What is Modules in Nodejs in Hindi, Types Of Modules in Nodejs in Hindi, How to use modules in Nodejs in Hindi आदि।
What is Nodejs in Hindi
Nodejs में Modules Set of Functions (Functions का Set) होता है। जिसे हम अपने Nodejs Application में Include कर सकते है।
Modules एक Block of Code होता है, जिसका Code हम अपने Project में Reuse कर सकते है। ये Same javascript Library की तरह होता है। जिसका use करने से हमें ज्यादा Code लिखने की आवश्यकता नहीं पड़ती है।
Types of Nodejs Modules in Hindi
Nodejs में Three types के Modules होते है।
Core Modules
Local Modules
Third Party Modules
1. Core Modules
Nodejs Core Modules में Minimum Functionalities include होती है। ये Nodejs Process Start होते ही Automatically Load हो जाते है। लेकिन इनको पहले हमें अपने project में Import करना होता है। इनको हम Require Function की मदद से Import (Load) कर सकते है।
var http = require('http');
| Modules name | Description |
|---|---|
| http | इससे हम Nodejs में Server Create कर सकते है। |
| assert | ये Set of Assertion Function होता है, testing के लिए |
| fs | इससे File System को handle कर सकते है। |
| path | इस Module की help से path के साथ deal कर सकते है। |
2. Local Modules
exports.add = function (x, y) {
return x + y;
};
exports.sub = function (x, y) {
return x - y;
};
exports.mult = function (x, y) {
return x * y;
};
exports.div = function (x, y) {
return x / y;
};
var calculator = require('./op');
var x = 25, y = 35;
console.log("Addition of 25 and 35 is "
+ calculator.add(x, y));
console.log("Subtraction of 25 and 35 is "
+ calculator.sub(x, y));
console.log("Multiplication of 25 and 35 is "
+ calculator.mult(x, y));
console.log("Division of 50 and 10 is "
+ calculator.div(x, y));
Addition of 25 and 35 is 60
Subtraction of 25 and 35 is -10
Multiplication of 25 and 35 is 875
Division of 25 and 35 is 0.7142857142857143

Comments
Post a Comment