Howto isset Method? without initilize instance - Javascript

This is a discussion on Howto isset Method? without initilize instance - Javascript ; loading.............. var a =function() { this.b=function(){}; } //howto isset this.b ? WITHOUT var g= new a(); // without instance var isset = g.b || false; connection closed....

+ Reply to Thread
Results 1 to 5 of 5

Howto isset Method? without initilize instance

  1. Default Howto isset Method? without initilize instance

    loading..............



    var a =function()
    {
    this.b=function(){};
    }

    //howto isset this.b ?
    WITHOUT

    var g= new a(); // without instance

    var isset = g.b || false;




    connection closed.


  2. Default Re: Howto isset Method? without initilize instance

    On May 11, 11:42 am, "mabo...@" <mabo...@> wrote:
    > loading..............
    >
    > var a =function()
    > {
    > this.b=function(){};
    >
    > }
    >
    > //howto isset this.b ?
    > WITHOUT
    >
    > var g= new a(); // without instance
    >
    > var isset = g.b || false;


    I don't really get what you are on about, my guess is that you want to
    test for g.b but don't know if g is defined in the first place. Maybe
    you want:

    var isset = !!(g && g.b);


    --
    Rob


  3. Default Re: Howto isset Method? without initilize instance

    RobG wrote:
    > On May 11, 11:42 am, "mabo...@" <mabo...@> wrote:
    >> loading..............
    >>
    >> var a =function()
    >> {
    >> this.b=function(){};
    >>
    >> }
    >>
    >> //howto isset this.b ?
    >> WITHOUT
    >>
    >> var g= new a(); // without instance
    >>
    >> var isset = g.b || false;

    >
    > I don't really get what you are on about, my guess is that you want to
    > test for g.b but don't know if g is defined in the first place. Maybe
    > you want:
    >
    > var isset = !!(g && g.b);


    Is that a magic trick?

    --
    -Lost
    Remove the extra words to reply by e-mail. Don't e-mail me. I am
    kidding. No I am not.

  4. Default Re: Howto isset Method? without initilize instance

    On May 11, 1:17 pm, -Lost <maventheextrawo...@techie.com> wrote:
    > RobG wrote:
    > > On May 11, 11:42 am, "mabo...@" <mabo...@> wrote:
    > >> loading..............

    >
    > >> var a =function()
    > >> {
    > >> this.b=function(){};

    >
    > >> }

    >
    > >> //howto isset this.b ?
    > >> WITHOUT

    >
    > >> var g= new a(); // without instance

    >
    > >> var isset = g.b || false;

    >
    > > I don't really get what you are on about, my guess is that you want to
    > > test for g.b but don't know if g is defined in the first place. Maybe
    > > you want:

    >
    > > var isset = !!(g && g.b);

    >
    > Is that a magic trick?


    No, it's using the && (AND) operator as what Douglas Crockford calls a
    "guard" operator.

    The expressions inside the brackets are evaluated from left to right
    until either one of them resolves to false (or its equivalent: null,
    undefined or numeric zero) or the last expression is reached.

    The value of the last expression evaluated is returned, whereupon !!
    converts it to boolean false (if it is one of the previously mentioned
    values) or true (for any other value).

    Note that strings '0' (zero), 'false', 'null', etc. resolve to true.


    --
    Rob


  5. Default Re: Howto isset Method? without initilize instance

    RobG wrote:
    > On May 11, 1:17 pm, -Lost <maventheextrawo...@techie.com> wrote:
    >> RobG wrote:
    >>> On May 11, 11:42 am, "mabo...@" <mabo...@> wrote:
    >>>> loading..............
    >>>> var a =function()
    >>>> {
    >>>> this.b=function(){};
    >>>> }
    >>>> //howto isset this.b ?
    >>>> WITHOUT
    >>>> var g= new a(); // without instance
    >>>> var isset = g.b || false;
    >>> I don't really get what you are on about, my guess is that you want to
    >>> test for g.b but don't know if g is defined in the first place. Maybe
    >>> you want:
    >>> var isset = !!(g && g.b);

    >> Is that a magic trick?

    >
    > No, it's using the && (AND) operator as what Douglas Crockford calls a
    > "guard" operator.
    >
    > The expressions inside the brackets are evaluated from left to right
    > until either one of them resolves to false (or its equivalent: null,
    > undefined or numeric zero) or the last expression is reached.
    >
    > The value of the last expression evaluated is returned, whereupon !!
    > converts it to boolean false (if it is one of the previously mentioned
    > values) or true (for any other value).
    >
    > Note that strings '0' (zero), 'false', 'null', etc. resolve to true.


    Ah yes, in the survey. I had forgotten about that. To be honest I did
    not quite understand it until your explanation. (Granted it is still
    remarkably fuzzy.)

    Thanks.

    --
    -Lost
    Remove the extra words to reply by e-mail. Don't e-mail me. I am
    kidding. No I am not.

+ Reply to Thread

Similar Threads

  1. module_eval is an instance method?
    By Application Development in forum RUBY
    Replies: 8
    Last Post: 11-26-2007, 02:33 PM
  2. Howto design my method?
    By Application Development in forum c++
    Replies: 8
    Last Post: 09-19-2007, 10:54 PM
  3. How to replace a method in an instance.
    By Application Development in forum Python
    Replies: 12
    Last Post: 08-27-2007, 10:08 AM
  4. instance method questions
    By Application Development in forum Python
    Replies: 2
    Last Post: 08-22-2007, 11:19 AM
  5. HttpServerUtility instance method
    By Application Development in forum DOTNET
    Replies: 1
    Last Post: 08-16-2007, 08:18 PM