+ 14
question
[]==new Array() ,{}==new Object() ,function(){}== new Function Can anybody explain this or provide any sources. It would be helpful to me.
2 odpowiedzi
+ 3
on the left side you have the shorthand notations and on the right side you have the "long" notations.
Create a new Array:
var arr1 = []; //creates an empty Array
var arr2 = new Array(); //also creates an empty Array
https://www.w3schools.com/js/js_arrays.asp
Create an Object:
var obj1 = {}; //creates a new Object without any properties
var obj2 = new Object(); //same as above
https://www.w3schools.com/js/js_objects.asp
Create a Function:
var func1(){}; creates a new function without parameters that does nothing.
var func2 = new Function()
https://www.w3schools.com/js/js_functions.asp
+ 7
Thanks. Very useful👍