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

Re: question about strict mode violation

Expand Messages
  • Douglas Crockford
    ... The use strict ; pragma is only meaningful at the first statement of a file or first statement of a function body. Anywhere else it is just a useless
    Message 1 of 5 , Jan 10, 2010
    • 0 Attachment
      > Is it valid ecmascript5 to switch from non-strict mode to strict mode within one file? That might happen by concatenating of a non-strict library and a "use strict" file. Worst case would be that future browser assume the whole file to be strict and thereby break the code.
      > I wondered because everybody is saying today "use as few files as possible or you and your site will be lame".


      The "use strict"; pragma is only meaningful at the first statement of a file or first statement of a function body. Anywhere else it is just a useless expression statement and is ignored.
    • walfisch_in_the_sea
      Ah, thanks.
      Message 2 of 5 , Jan 11, 2010
      • 0 Attachment
        Ah, thanks.


        --- In jslint_com@yahoogroups.com, "Douglas Crockford" <douglas@...> wrote:
        >
        > > Is it valid ecmascript5 to switch from non-strict mode to strict mode within one file? That might happen by concatenating of a non-strict library and a "use strict" file. Worst case would be that future browser assume the whole file to be strict and thereby break the code.
        > > I wondered because everybody is saying today "use as few files as possible or you and your site will be lame".
        >
        >
        > The "use strict"; pragma is only meaningful at the first statement of a file or first statement of a function body. Anywhere else it is just a useless expression statement and is ignored.
        >
      Your message has been successfully submitted and would be delivered to recipients shortly.