Loading ...
Sorry, an error occurred while loading the content.
 

"The Function constructor is eval." - eval or evil?

Expand Messages
  • kevin_hakanson
    I was looking through the fulljslint.js source and ran across the snippet below. Should the message say ... is evil ? Is this some sort of Freudian slip?
    Message 1 of 3 , Jun 27, 2008
      I was looking through the fulljslint.js source and ran across the
      snippet below. Should the message say "... is evil"? Is this some
      sort of Freudian slip? :)

      case 'Function':
      if (!option.evil) {
      warning("The Function constructor is eval.");
      }
      break;
    • Douglas Crockford
      ... It was intentional. The Function constructor is a form of eval.
      Message 2 of 3 , Jun 29, 2008
        --- In jslint_com@yahoogroups.com, "kevin_hakanson"
        <kevin.hakanson@...> wrote:
        >
        > I was looking through the fulljslint.js source and ran across the
        > snippet below. Should the message say "... is evil"? Is this some
        > sort of Freudian slip? :)
        >
        > case 'Function':
        > if (!option.evil) {
        > warning("The Function constructor is eval.");
        > }
        > break;

        It was intentional. The Function constructor is a form of eval.
      • kevin_hakanson
        ... Between the time I posted this and you replied, I read JavaScript: The Good Parts and now that makes sense. I had never thought of using new
        Message 3 of 3 , Jun 30, 2008
          --- In jslint_com@yahoogroups.com, "Douglas Crockford" <douglas@...>
          wrote:
          >
          > --- In jslint_com@yahoogroups.com, "kevin_hakanson"
          > <kevin.hakanson@> wrote:
          > >
          > > I was looking through the fulljslint.js source and ran across the
          > > snippet below. Should the message say "... is evil"? Is this some
          > > sort of Freudian slip? :)
          > >
          > > case 'Function':
          > > if (!option.evil) {
          > > warning("The Function constructor is eval.");
          > > }
          > > break;
          >
          > It was intentional. The Function constructor is a form of eval.
          >

          Between the time I posted this and you replied, I read "JavaScript:
          The Good Parts" and now that makes sense. I had never thought of
          using new Function(...) before, so I am glad that is a "bad part" I
          never learned.

          Would you consider updating the warning message to be "The Function
          constructor is a form of eval.", which adds "a form of" to the text?
          You do something similar with "document.write can be a form of eval."
        Your message has been successfully submitted and would be delivered to recipients shortly.