I want to ask a question about JavaScript variable declaration.
I am learning about node.js and I just started declaring the packages that I need for an application:
var bodyParser = require("body-parser"),
mongoose = require("mongoose"),
express = require("express"),
app = express();
but I was wondering something about the lines above.
When I was learning programming languages first, the elementary lesson was about variables and their declaration:
var myString = "Hello World"
var myNumber = 5
where each variable is defined separately on a new line. But, in the block of code that I've been presented with, I was struggling to understand what was happening.
My idea is that we are declaring out individual variables without the repetition of the var
keyword:
var bodyParser = require("body-parser");
var mongoose = require("mongoose");
var express = require("express");
var app = express();
This, I thought, would be the longer way around the matter. However, I failed to find any documentation to support my educated guess.
Am I declaring individual variables without repetition of the keyword var
or am I doing something else?