Book Image

Learning Node.js for .NET Developers

Book Image

Learning Node.js for .NET Developers

Overview of this book

Node.js is an open source, cross-platform runtime environment that allows you to use JavaScript to develop server-side web applications. This short guide will help you develop applications using JavaScript and Node.js, leverage your existing programming skills from .NET or Java, and make the most of these other platforms through understanding the Node.js programming model. You will learn how to build web applications and APIs in Node, discover packages in the Node.js ecosystem, test and deploy your Node.js code, and more. Finally, you will discover how to integrate Node.js and .NET code.
Table of Contents (21 chapters)
Learning Node.js for .NET Developers
About the Author
About the Reviewer

Introducing JavaScript types

JavaScript is a dynamically-typed language. These means that types are checked at runtime when you try to do something with a variable, rather than by a compiler. For example, the following is valid JavaScript code:

var myVariable = 0; 
console.log(typeof myVariable); // Prints "number"
myVariable = "1";
console.log(typeof myVariable); // Prints "string"

Although variables do have a type, this may change throughout the lifetime of the variable.

JavaScript also tries to implicitly convert types where possible, for example, using the equality operator:

console.log(2 == "2"); // Prints "true"

Although this might make sense for frontend JavaScript (for example comparing against the value of a form input), in general, it is more likely to be a source of errors or confusion. For this reason, it is recommended to always use the strict equality and inequality operators:

console.log(2 === "2"); // Prints "false"
console.log(2 !== "2"); // Prints "true"

JavaScript primitive types...