What does = = mean mean in node js
I am learning node js and have come across " =>" several times , however I try to understand what this means.
Here is an example:
app.post('/add-item', (req, res) => {
// TODO: add an item to be posted
});
Do we really need this in the above example? A simple explanation would be helpful. Thanks
It's nothing node-exclusive, it's an expression of the ES6 Arrow function
app.post('/add-item', (req, res) => {
// TODO: add an item to be posted
});
basically means:
app.post('/add-item', function(req, res) {
// TODO: add an item to be posted
});
The main difference between the two examples is that the former lexically relates meaning this.