Questions tagged [truthy]
If `not(x)` is the Boolean negation function of a programming language, then a value, x, may be said to be truthy in that language if and only if not(not(x)) evaluates to the Boolean value `true`.
truthy
14
questions
2
votes
3
answers
212
views
Checking for False when variable can also be None or True
Update: please see my discussion if you want to delve further into this topic! Thank you everyone for your feedback on this!
I have a boolean(ish) flag that can be True or False, with None as an ...
0
votes
1
answer
886
views
How do I check truthy when using Ternary Operator
I am having issues with using the ternary operator and checking if a value is truthy or not. I have a feeling that my syntax is incorrect. Below is the instructions on what I need to do to pass this ...
1
vote
2
answers
89
views
Strange behaviour of the alternative operator //
Using JQ 1.5 I've problems understanding the output of the alternative operator // in a specific situation.
Given this input:
{
"a": 42,
"b": false,
"c": null
...
0
votes
2
answers
246
views
How to return a new array with all truthy values removed? (Javascript)
I have seen how to remove falsy values from an array but haven't found a solution for returning a new array with all truthy elements removed. I attempted to replace falsy values with truthy ones in my ...
1
vote
1
answer
147
views
Using the boolean "True" as an expression to evaluate in a while loop
I recently was making a little script that would ask for tv series titles and logs them on the console in an array. I used a keyword to stop the loop which is 'terminate' and it should not be included,...
2
votes
1
answer
264
views
PHP - what is the point of using isSet() and checking for truthy value?
I saw this in my codebase today:
if (isset($purchase_data['buyer_tracking_address_id']) && $purchase_data['buyer_tracking_address_id']) {
// do something
}
Why would checking for both ...
2
votes
2
answers
1k
views
How to check if variable is not falsy but 0 passes in Javascript
Is there an elegant way to check if variable is NOT falsy but in case of 0 it passes. The issue with this way of verifying
if(var !== undefined && var !== null)
is that it's long and doesn't ...
0
votes
2
answers
708
views
trouble with truthy/falsey
A quick intro, I am a total noob learning JS and feel that it's going well, however I am doing a simple exercise right now and I'm hung up on something.
I have learned that:
a falsey value is a value ...
2
votes
1
answer
262
views
Python Pandas & operator not returning right values
In the code:
df = pd.DataFrame([[False, 0], [False, 1], [False, 2], [False, 2], [False, 3], [False, 4], [False, 5]],
columns=['cond1', 'cond2'])
df['test'] = (~df['cond1']) & (df['cond2'])...
1
vote
2
answers
478
views
How can I check this function for truthy or return an empty array if falsy?
I am looking at this assignment, and my question is about the part in bold at the end:
// Do not edit the code below.
var myGroceryList = ['chips', 'pizza', 'hotpockets', 'MtnDew', 'corndogs'];
// Do ...
2
votes
1
answer
165
views
How to select a subset of elements of the input R6 class within a shiny module to perform operations on them
Can I access a list of all input widgets within a module (let us name it myModule) and check if their state is isTruthy().
I found a way that works when I know (or can deduce) the exact names of the ...
1
vote
2
answers
355
views
This condition returns a boolean when checking for a falsy, but it returns a string when checking for a truthy value. How can I get it to work? [duplicate]
I get a boolean return when checking for a falsy value, but not a boolean when checking for a truthy value... I am just getting a string instead.
This works.
const isFalse = !values.firstName &&...
31
votes
3
answers
24k
views
Type for non-false, aka truthy
In TypeScript, is there a type for truthy?
I have this method:
Object.keys(lck.lockholders).length;
enqueue(k: any, obj?: any): void
I think with TS there is a way to check for empty strings '', ...
11
votes
2
answers
9k
views
What is the difference between truthy and falsy with true and false in JavaScript?
I have a question concerning some concepts in JavaScript such as (truthy, true) and (falsy, false).
I know the type of 1 is not true but the question is: why 1 == true?
What was the main reason of ...