Node.js by Example: Values

Javascript has various value types including strings, numbers, booleans, etc. Here are a few basic examples.

Strings, which can be added together with +.

console.log("node" + ".js");

Javascript has one number type.

console.log("1+1 =", 1 + 1);

It can be used for both integers and decimals.

console.log("7.0/3.0 =", 7.0 / 3.0);

Booleans, with boolean operators as you’d expect.

console.log(true && false);
console.log(true || false);
console.log(!true);
$ node values.js
node.js
1+1 = 2
7.0/3.0 = 2.3333333333333335
false
true
false

Next example: .