javascript - what does new Function()() mean? -


I saw this code while working on a project and I'm not sure what it actually does. Someone reads me please thanks.

  var f = new function ('return' + conditions) ($ element); Return F ($ element);   

New function () () I look like an instant-incompatible function expression, and if this happens then it would be correct with the 'return' terms' expression? Then why is the function called F in the return statement?

Updates:

  1. There is an array in words in which there is only one element 'required', $ element is a jQuery object of an HTML element
  2. Never execute code New message with past message () is not defined Uncaught ReferenceError: Required is not defined therefore new function () () () Function requirement () is implemented.
  3. I've never seen new function () () syntax If it is an IEEE then it should not be written as (new function () {}) () ?

    Yes, you are right that this is an unblocked function - you can do it yourself Can test:

      var f = new function ("return" one '') ('b'); console.log (f);   

    is a function that represents a string of a function, whose Meaning:

      var f = new function ("return function" ('return logic') ") (); Console.log (f, f (5));   

    function anonymous () {return logic} [5]

    No need to say, this is a typical way to write JS is.

    About updates:

    What really happens if terms = ['required'] it turns into a string ' Return ', therefore you have a new function ("return' required '') . Since this is the function that gives' code 'required' Trying to be called as function - Required ($ elem) will actually give a reference error. New function ("expected return") Since it is a work that is

    No, it is an acceptable way of writing. The function created without the use of the object In the case of (function () {}) () . new function ("[function body]") () () Code> Operating successfully due to operator preference function () {} () error Will Pnn.

Comments

Popular posts from this blog

ios - Adding an SKSpriteNode to SKScene from a child SKSpriteNode -

Matlab transpose a table vector -

c# - Textbox not clickable but editable -