How that JavaScript will resolve?

I am using some node.js code and there is one line in that code. Can any one help me how that following javascript code will resolve?

var silent = 'test' == process.env.NODE_ENV;

why that code use = and == at one line? I guess its a kind for shorthand coding style but I do not know what will be its full-form.

The var, variable declaration statement works from the left most expression to the right. The left hand side expression is evaluated first and then the right hand side expression. So, it creates a variable silent and then assigns the result of the comparison to it.

Parenthesis would have helped to understand this better,

var silent = ('test' == process.env.NODE_ENV);

This checks if the environmental variable NODE_ENV is equal to "test" or not. And the boolean result will be used to initialize the newly created variable silent, at runtime.

It will resolve to a boolean value ( true/ false ):

// if process.env.NODE_ENV is 'test'
var silent = 'test' == process.env.NODE_ENV;
console.log(silent); // true

// if process.env.NODE_ENV is 'production'
var silent = 'test' == process.env.NODE_ENV;
console.log(silent); // false

The developer is doing this for semantic value. He could done:

var silent;
if ('test' == process.env.NODE_ENV){
    silent = true;
}
else {
    silent = false;
}

but this is less succinct and poignant.