logical && and logical ||
evdama opened this issue · 2 comments
evdama commented
I was wondering if there's a is.js way to replace the &&
with? This snippet for example
if ( is.object( request.useragent ) && is.propertyDefined( request.useragent, 'isBot' ) ) {
// both conditions are truthy
} else {
// at least one condition is falsy
}
can't be written as
if ( is.all.truthy( is.object( request.useragent ) is.propertyDefined( request.useragent, 'isBot' ) ) ) {
// both conditions are truthy
} else {
// at least one condition is falsy
}
or am I missing something simple here?
ironmaniiith commented
You can ofcourse use is.truthy which supports the all (and any) interface in order to have an equivalent functionality for &&
and ||
In your case, you can either give comma separated values to is.all.truthy
or you can pass an array as well.
evdama commented
gosh, sure, thanks much... closing :)