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

Re: [jslint] Re: "unnamed" Parameter Option

Expand Messages
  • Marcel Duran
    ... function f (o) { ....if (o && typeof o.foo !== undefined ) { ........// do something with o.foo ....} ....if (o && typeof o.bar !== undefined &&
    Message 1 of 9 , Sep 20, 2011
      On Tue, Sep 20, 2011 at 1:47 PM, Xavier MONTILLET wrote:

      > **
      >
      >
      > Plus arguments is the only way to determine if an argument was omitted or
      > if
      > it was given the value undefined. Which should react differently on
      > functions that are both getters and setters.
      >
      > Not necessarily, one can use object and arrays to mimmic arguments, e.g.:

      function f (o) {
      ....if (o && typeof o.foo !== 'undefined') {
      ........// do something with o.foo
      ....}
      ....if (o && typeof o.bar !== 'undefined' &&
      yourFavoriteArrayCheckFunction(o.bar)) {
      ........// iterate o.bar
      ....}
      }

      f({foo: true, bar: ['abc', 'def', 'ghi']});
      f({foo: true});
      f({bar: ['abc', 'def', 'ghi']});
      f({foo: true, bar: ['abc', 'def', 'ghi'], baz: 'something'});
      f({baz: 'something'});
      f({});
      f();

      --
      Marcel Duran


      [Non-text portions of this message have been removed]
    • sandyhead25
      Simple. Change the format of input to an object literal. Then you can have a variable number of named parameters. Consider the following: var args = {first:
      Message 2 of 9 , Sep 21, 2011
        Simple. Change the format of input to an object literal. Then you can have a variable number of named parameters. Consider the following:

        var args = {first: "x", second: "y", third: "z"},
        mycode = function (args) {
        //args.first === "x";
        };

        Here is an actual living example from a real application:
        https://github.com/austincheney/Pretty-Diff/blob/master/markup_beauty.js

        --- In jslint_com@yahoogroups.com, Robert Ferney <capnregex@...> wrote:
        >
        > 'arguments' is leaving the language?
        > So, how do we handle functions that accept a variable number of arguments?
        >
        > - Robert Ferney
        >
        >
        >
        >
        > On Tue, Sep 20, 2011 at 9:11 AM, Douglas Crockford <douglas@...>wrote:
        >
        > > **
        > >
        > >
        > > --- In jslint_com@yahoogroups.com, "benxwhite" <ben.a.white@> wrote:
        > > >
        > > > It would be nice if there was an option to disable the "Use a named
        > > parameter" check.
        > >
        > > arguments will be leaving the language.
        > > Start getting used to not using it.
        > >
        > >
        > >
        >
        >
        > [Non-text portions of this message have been removed]
        >
      • Xavier MONTILLET
        I don t get the point of removing arguments if it forces you to ask for an array as argument... ... [Non-text portions of this message have been removed]
        Message 3 of 9 , Sep 21, 2011
          I don't get the point of removing arguments if it forces you to ask for an
          array as argument...

          On Wed, Sep 21, 2011 at 7:04 PM, sandyhead25 <austin.cheney@...>wrote:

          > **
          >
          >
          > Simple. Change the format of input to an object literal. Then you can have
          > a variable number of named parameters. Consider the following:
          >
          > var args = {first: "x", second: "y", third: "z"},
          > mycode = function (args) {
          > //args.first === "x";
          > };
          >
          > Here is an actual living example from a real application:
          > https://github.com/austincheney/Pretty-Diff/blob/master/markup_beauty.js
          >
          >
          > --- In jslint_com@yahoogroups.com, Robert Ferney <capnregex@...> wrote:
          > >
          > > 'arguments' is leaving the language?
          > > So, how do we handle functions that accept a variable number of
          > arguments?
          > >
          > > - Robert Ferney
          > >
          > >
          > >
          > >
          > > On Tue, Sep 20, 2011 at 9:11 AM, Douglas Crockford <douglas@...>wrote:
          >
          > >
          > > > **
          > > >
          > > >
          > > > --- In jslint_com@yahoogroups.com, "benxwhite" <ben.a.white@> wrote:
          > > > >
          > > > > It would be nice if there was an option to disable the "Use a named
          > > > parameter" check.
          > > >
          > > > arguments will be leaving the language.
          > > > Start getting used to not using it.
          > > >
          > > >
          > > >
          > >
          > >
          > > [Non-text portions of this message have been removed]
          > >
          >
          >
          >


          [Non-text portions of this message have been removed]
        • sandyhead25
          Could you rephrase that? I am not sure what you are asking.
          Message 4 of 9 , Sep 22, 2011
            Could you rephrase that? I am not sure what you are asking.

            --- In jslint_com@yahoogroups.com, Xavier MONTILLET <xavierm02.net@...> wrote:
            >
            > I don't get the point of removing arguments if it forces you to ask for an
            > array as argument...
            >
            > On Wed, Sep 21, 2011 at 7:04 PM, sandyhead25 <austin.cheney@...>wrote:
            >
            > > **
            > >
            > >
            > > Simple. Change the format of input to an object literal. Then you can have
            > > a variable number of named parameters. Consider the following:
            > >
            > > var args = {first: "x", second: "y", third: "z"},
            > > mycode = function (args) {
            > > //args.first === "x";
            > > };
            > >
            > > Here is an actual living example from a real application:
            > > https://github.com/austincheney/Pretty-Diff/blob/master/markup_beauty.js
            > >
          Your message has been successfully submitted and would be delivered to recipients shortly.