I was doing a bit of reading when I found Array.of.
As per MDN,
The Array.of() method creates a new Array instance with a variable number of arguments, regardless of number or type of the arguments.
var a = Array.of(1,2,3,4,5);
console.log(a)
But if I already know the values, I can also wrap them in [] to get same output. So is there a specific scenario when we can/should use Array.of? Also is there any benefit of using it over []?
Edit 1:
Objective of this question is difference between Array.of vs [] and not new Array vs Array.of
Array.of = function() { return Array.prototype.slice.call(arguments); };fn().map(Array.of)vsfn().map((...args) => [...args])