Following are the key points described later in this article:
var drawTraingle = function() {
console.log("Traingle drawn");
}
var drawCircle = function() {
console.log("Circle drawn");
}
Above code could be saved as draw.js. The file draw.js could be used to represent a module representing functions to draw different shapes. As per this page, module.exports is the object that’s actually returned as the result of a require call.
module.exports = {
drawTraingle: function() {
console.log("Traingle drawn");
},
drawCircle: function() {
console.log("Circle drawn");
}
};
The above code could also be written as following:
var drawTraingle = function() {
console.log("Traingle drawn");
};
var drawCircle = function() {
console.log("Circle drawn");
};
exports.drawTraingle = drawTraingle;
exports.drawCircle = drawCircle;
Following code represents how the above function can be used in other file, say, main.js
var d = require("./draw.js");
d.drawTraingle();
d.drawCircle();
Pay attention to usage of “require” function.
node main.js
It would print following:
Traingle drawn
Circle drawn
In recent years, artificial intelligence (AI) has evolved to include more sophisticated and capable agents,…
Adaptive learning helps in tailoring learning experiences to fit the unique needs of each student.…
With the increasing demand for more powerful machine learning (ML) systems that can handle diverse…
Anxiety is a common mental health condition that affects millions of people around the world.…
In machine learning, confounder features or variables can significantly affect the accuracy and validity of…
Last updated: 26 Sept, 2024 Credit card fraud detection is a major concern for credit…