It looks pretty valid to me.
One nuance of javascript that you might not be aware of is that boolean
operators return a corresponding value. In the case of OR that is the first
"truthy" value. In your case, with a function that itself returns a boolean,
it probably doesn't make any difference but consider the following:
var a = false,
b = "yay",
c = "foo",
d;
d = a || b || c;
console.log(c); // outputs "yay"
AND, on the other hand, returns the last value assuming all are truthy:
var a = true,
b = "yay",
c = "foo",
d;
d = a && b && c;
console.log(d); // outputs "foo"
On 21 Nov 2011, at 14:43, pixelboy wrote:
> Dear mentors,
>
> I have a quick tip i'm trying to "verify". Is the creation of
>
> var valid = this._isJson(settings) || this._isJson(products);
>
> where isJson returns a boolean.
> Is this simple snippet valid, or could I be missing some js nuance ?
>
> Thanks for your valuable time.
>
> --
> To view archived discussions from the original JSMentors Mailman list:
> http://www.mail-archive.com/[email protected]/
>
> To search via a non-Google archive, visit here:
> http://www.mail-archive.com/[email protected]/
>
> To unsubscribe from this group, send email to
> [email protected]
--
To view archived discussions from the original JSMentors Mailman list:
http://www.mail-archive.com/[email protected]/
To search via a non-Google archive, visit here:
http://www.mail-archive.com/[email protected]/
To unsubscribe from this group, send email to
[email protected]