Tuesday, 11 April 2017

Is there any difference between javascript engine used in node and crome browser?

I have run following code in both crome broswer console and thru node engine, got different result

code:

function foo() {
    console.log(this.a);
}

var a = 10;

foo();

output in Crome browser: 10

and when I saved above code in main.js file run below command

node main.js

output: undefined



via abhicool

No comments:

Post a Comment