Book Image

Web Development with MongoDB and NodeJS Second edition

Book Image

Web Development with MongoDB and NodeJS Second edition

Overview of this book

Table of Contents (19 chapters)
Web Development with MongoDB and NodeJS Second Edition
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
12
Popular Node.js Web Frameworks
Index

A JavaScript primer


As we already know Node.js is not just another language, but JavaScript. The language syntax and tools you are used to while coding JavaScript on the browser will work verbatim on the server. Node.js has additional tools that are only available on the server, but the language and syntax again are the same as JavaScript. I'm assuming you have a general understanding of the basic JavaScript syntax, but I will introduce JavaScript to you with a very brief primer on the language just in case.

In general, JavaScript is a fairly simple language when it comes to syntax, and you only need to know a few important elements.

Syntax basics

The most basic thing you can do in pretty much any programming language is declare a variable. Unlike most other languages, JavaScript is a dynamically typed language, which means when you declare a variable, its value can be of any type and can change during the course of its lifetime. However, in contrast, a strongly typed language dictates that...