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

[jslint] Re: explanations for some options

Expand Messages
  • Douglas Crockford
    ... Not true. typeof remains broken. An Array.isArray method is added. ... Not exactly. this will be bound to undefined, which might result in throwing. ...
    Message 1 of 6 , Jul 21, 2010
    View Source
    • 0 Attachment
      --- In jslint_com@yahoogroups.com, "pauanyu" <pcxunlimited@...> wrote:

      > Some benefits of ECMAScript 5 strict mode:
      >
      > typeof [] returns "array" rather than "object"
      > typeof null returns "null" rather than "object"

      Not true. typeof remains broken. An Array.isArray method is added.

      > If you forget to use "new" when using a constructor, like new Foobar(), it will throw an error. Before, it would silently attach the constructor's properties to the global object (usually window).

      Not exactly. this will be bound to undefined, which might result in throwing.


      > The special "this" variable correctly propagates within inner functions. For instance, this code will run correctly:
      >
      > var foo = {
      > message: "Hello world",
      > saySomething: function () {
      > return (function () {
      > return this.message;
      > }());
      > }
      > };

      Not true. this in all inner functions is undefined.
    • pauanyu
      Really! I heard talk about typeof being fixed. I guess they figured it would cause too many compatibility problems so they cut it? I also recall hearing about
      Message 2 of 6 , Jul 21, 2010
      View Source
      • 0 Attachment
        Really! I heard talk about typeof being fixed. I guess they figured it would cause too many compatibility problems so they cut it?

        I also recall hearing about "this" being properly bound while within inner functions. I wonder why that was changed.

        Either way, sorry for the misinformation.

        --- In jslint_com@yahoogroups.com, "Douglas Crockford" <douglas@...> wrote:
        >
        > --- In jslint_com@yahoogroups.com, "pauanyu" <pcxunlimited@> wrote:
        >
        > > Some benefits of ECMAScript 5 strict mode:
        > >
        > > typeof [] returns "array" rather than "object"
        > > typeof null returns "null" rather than "object"
        >
        > Not true. typeof remains broken. An Array.isArray method is added.
        >
        > > If you forget to use "new" when using a constructor, like new Foobar(), it will throw an error. Before, it would silently attach the constructor's properties to the global object (usually window).
        >
        > Not exactly. this will be bound to undefined, which might result in throwing.
        >
        >
        > > The special "this" variable correctly propagates within inner functions. For instance, this code will run correctly:
        > >
        > > var foo = {
        > > message: "Hello world",
        > > saySomething: function () {
        > > return (function () {
        > > return this.message;
        > > }());
        > > }
        > > };
        >
        > Not true. this in all inner functions is undefined.
        >
      Your message has been successfully submitted and would be delivered to recipients shortly.