Node.js modules are set of functions that are used to include in your application.It is very similar to the libraries in javascript. When involving in development, we can either use built in modules or else we can create our own modules. Usually Modules are not designed in the same file that we are developing in. Modules are created and stored in separate files for the easy use. So lets create a separate file to create a module.I have created a file called module.js for further proceedings Now I am going to create a basic module to count the number of elements in an array in my new file. var value =function(array){ return array.length + ' elements are there'; }; console.log(value(['A','B','C','D'])); Now run the command line and check the output Now we have created our module in an separate file.Now we should make this function available outside the module.js file.For that type the following code in module.js file. modu...
Comments
Post a Comment