Node JS

Node JS is a runtime environment.

V8 engine by Google.


Console is provided by runtime environment not by JS.

JS is slow than C++ and Java

 

 

 setTimeout()

 

 
    function cooker(){
        console.log("vegtable cooked");
    }

    function cooking(){
        console.log("Chopped vegetable");
        // cooker();
        setTimeout(cooker,1000);
        console.log("dough ready");
    }

    cooking();



.





    function cooker(){
        console.log("vegtable cooked");
    }

    function cooking(){
        console.log("Chopped vegetable");
        // cooker();
        setTimeout(cooker,1000);
        setTimeout(()=> {            
            console.log("Watching TV")
        }, 2000);
        console.log("dough ready");
    }

    cooking();






LIFO---> Last In Fast Out.

FIFO----> First In Fast Out.


Modules/Packages : Any kind of code that is written by someOne. 

It is peace of code that help to solve problem is called Module.



Built in Module: Someone built this.

User Define Module: u make this module.

External Modules: Someone create and share on internet.


 
    // Module/ Packages

    // import file system module
    const fs = require('fs');
    const pathOfDir = "C:\\Users\\saeed\\Folder\\Desktop\\JS"
    fs.readdir(pathOfDir,(err, files)=>{
        console.log(err);
        console.log(files);
    });
 
 
 
      
    Output:  
 
    null
    [
      '10Feb.js',             '11Feb.js',
      '12Feb.js',             '19Feb.js',
      '26Frb.js',             '4Feb.js',
      '5Feb.js',              '5thFeb.js',
      '6Feb.js',              '7Feb.js',
      'astroGoru.js',         'astroGuru.js',
      'basicJsCalculator.js', 'freeCodeCamp.js',
      'HcfGcf.js',            'mosh',
      'myBlog.js',            'nde.js',
      'nodeJS',               'node_modules',
      'Others',               'p1.js',
      'P2.js',                'package-lock.json',
      'package.json'
    ]
 
 
 



Node JS Documentation Click Here




NPM ---> It's help u get u all the packages online.





إرسال تعليق (0)
أحدث أقدم