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

SV: [jslint] Re: global use strict

Expand Messages
  • Jakob Kruse
    You could try something like: var MyClass = function () { ”use strict”; return new Class(…); }(); /Jakob Fra: jslint_com@yahoogroups.com
    Message 1 of 1 , Jan 26, 2011
    • 0 Attachment
      You could try something like:

      var MyClass = function () { ”use strict”; return new Class(…); }();

      /Jakob


      Fra: jslint_com@yahoogroups.com [mailto:jslint_com@yahoogroups.com] På vegne af Woomla
      Sendt: 26. januar 2011 14:21
      Til: jslint_com@yahoogroups.com
      Emne: [jslint] Re: global use strict


      As I use mootools I have code like:

      var MyClass = new Class(
      {
      Implements: [Options],

      initialize: function (options)
      {
      this.setOptions(options)
      },

      myfunction001: function ()
      {
      },

      //a lot more functions

      myfunction999: function ()
      {
      }
      };

      I cannot put this in a function scope because then other files cannot access it. So I guess the only way to do is to insert "use strict" in all those functions.

      > This should prevent the file loading problem...

      Where can I find more information about this "file loading problem".

      --- In jslint_com@yahoogroups.com, Morgaut Alexandre Louis Marc <morgaut@...> wrote:
      >
      >
      > I found the function level bieng less a problem as I often start my code creating a function scope
      >
      > this way, I juest had to change my code from
      >
      >
      > "use strict";
      >
      > (function Scope_Myapp() {
      >
      > // my app code
      >
      > }());
      >
      >
      >
      > to
      >
      > (function Scope_Myapp() {
      >
      > "use strict";
      >
      > // my app code
      >
      > }());
      >
      >
      > And all my functions inherit from the strictness of my scope function
      >
      > This should prevent the file loading problem...
      >
      >
      >
      > On Jan 25, 2011, at 1:39 PM, Zhami wrote:
      >
      > >
      > >
      > > --- In jslint_com@yahoogroups.com, "Douglas Crockford" <douglas@> wrote:
      > > >
      > > > --- In jslint_com@yahoogroups.com, "Woomla" <woomla@> wrote:
      > > > > I really would have "use strict"; at the top of my files instead of in every function.
      > > > >
      > > > > Off course, concatinating files on the fly, and merging third party javascript, is a little harder, but I don't suffer from that. I have many functions that needs the statement inserted and, because I can use the statement at the file level, I prefer not to do it per function to keep my code clean and speed up development.
      > > >
      > > >
      > > > I would have too, but given the terrible performance characteristics of browsers with respect to script loading, file level strictness is not safe.
      > > >
      > > > If you are not suffering now, you would be suffering later.
      > > >
      > >
      > > What is it about browser script loading that makes file level strictness not safe: Is it that the "use strict" at a file level applies on a global level and not just to the loaded file? What about cases where all the code loaded is strict-compliant? Would it then not be safe? Or does "use strict" at a file level reach beyond loaded scripts and somehow apply to the operation of the compiler/interpreter itself (which may not be strict-compliant)?
      > >
      > >
      >
      >
      >
      > [Non-text portions of this message have been removed]
      >


      [Non-text portions of this message have been removed]
    Your message has been successfully submitted and would be delivered to recipients shortly.