I sometimes see people doing this Function(\'alert(\"hi\")\') and sometimes they do new Function(\'alert(\"hi\")\')
Is there a difference b
There is only one usage of new Function. It is this:
var constructor = new Function;
// then this
constructor.prototype = {
//... stuff
};
// OR
constructor.prototype = new someOtherThing;
// then
var obj = new constructor;
Basically you can use new Function if you want to create an object constructor with an empty constructor that only uses inheritance.
If you want a function to do anything then don't use Function at all.