Node Fundamentals in JavaScript

 

nodejs

Node VM

  • v8, Default, Single-Threaded
  • Chakra by Microsoft, powers Edge browser

VM executes the Java script code. So, v8 actually executes your JS code when you run a node application.


v8 Feature Groups

  • Shipping - Available by default
  • Staged - Not quite ready yet. flag --harmony
  • In-Progress - Less stable.

You can see the list of all group features by


Using Variables In Node js

In node js you can also assign or use Variables , but here in this example we are discussing about JavaScript with Node js


Here is an Example 

 
    var x = 199;
    var y = 30;

    console.log(x+y);

to make an output use this command :: node ----.js

Using Conditions in Node js

   
    var x = 199;
    if (x===20)
    {
        console.log("matched")
    }


Using for loops in Node js

 
    var x = 199;
    for(i=0; i<10 ; i++){
        console.log(i)
    }


Events on Node js

        var fs = require('fs');
        var rs = fs.createReadStream('./demo.txt');
        rs.on('open',function(){
            console.log("demo file is open");
        })
       

    Console in Node JS