Following a nodejs course(NodeJS in Action - manning's book) I saw this piece of code
// create server
var server = http.createServer(function(request, response){
var filePath = false;
if (request.url == '/') {
filePath = 'public/index.html';
} else {
filePath = 'public' + request.url;
}
var absPath = './' + filePath;
serveStatic(response, cache, absPath);
});
server.listen(3000, function(){
console.log('Server listening on port 3000.');
});
My question is about the variable "filePath". It is being initialized to false, but later it takes string values.
The editor I use (Visual Studio Code) shows me a warning:
Type 'string' is not assignable to type 'boolean'
My knowledge of javascript is not so deep, but I know it is loosely typed. So here is my question.
Is this initialization to false because of something? Any reaston to do so? Is my editor's warning wrong...? Or just the author's common practice.