+ 14

question

[]==new Array() ,{}==new Object() ,function(){}== new Function Can anybody explain this or provide any sources. It would be helpful to me.

20th Feb 2019, 2:18 PM
Ozair Khan
Ozair Khan - avatar
2 Respostas
+ 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
26th Feb 2019, 1:17 AM
Pete Wright
Pete Wright - avatar
+ 7
Thanks. Very useful👍
5th Mar 2019, 7:02 PM
Ozair Khan
Ozair Khan - avatar