My understanding is that when you want to create a new object in Javascript, it's best to use JSON notation:
let foo1 = {};
let foo2 = {};
foo1 = `Hola ${user}`;
foo2.name = user;
So I have been surprised when, when reviewing code that has been bequeathed to me, I have found something like:
let httpResponse = null;
if (condition) {
httpResponse = 'Error processing request'
} else {
httpResponse = JSON.parse(data)
}
Why have my peers put null to initialize the object? Are there differences between both ways?