question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

'truthy' and 'falsy' should be chainable properties.

See original GitHub issue

Especially since the description for ok actually uses the word truthy.

Issue Analytics

  • State:closed
  • Created 10 years ago
  • Reactions:37
  • Comments:10 (1 by maintainers)

github_iconTop GitHub Comments

34reactions
codewithkristiancommented, Mar 18, 2014

Realize this is closed, but giving this a 👍 because I also think that “truthy”/“falsy” is more clear than “ok”.

25reactions
jamestalmagecommented, Jan 25, 2014

Consider this fairly common scenario: Some API’s return a result object which may or may not have a property error. The presence of said property indicates that there was … an error. So while writing a test where I expect an error, I might do something like this:

var result = someActionThatShouldProduceAnError();
expect(result.error).to.be.ok;

That is potentially confusing to someone who isn’t familiar with chai. The following is easier to understand.

expect(result.error).to.be.truthy

If you google “javascript ok” vs. “javascript truthy”, I think it shows that truthy is a better choice than ok.

Chai is full of redundant syntax, so rejection on that basis seems arbitrary.

  • above, gt, greaterThan
  • equal, equals, eq
  • include, contain

I could be persuaded to give up on falsy in favor of not.truthy, but I’d ask you to reconsider rejecting the idea in its entirety.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to check for falsy values in properties of a chain of ...
I could get the code to work by using the Conditional (ternary) operator and checking for falsy values as below: let locationDistrict =...
Read more >
If Statements, Function Returns, Truthy and Falsy - Wes Bos
You can also chain these "else ifs" as many times as you want. However, if the first one is true, even if the...
Read more >
The Semantics of Falsy Values - DEV Community ‍ ‍
Just like empty arrays, empty objects are considered to be "truthy" by the language specification. For the sake of this article, I will...
Read more >
Truthy and Falsy Values: When All is Not Equal in JavaScript
Anything in JavaScript can be considered truthy or falsy. Learn what these values are and the rules that apply when they're compared.
Read more >
Logical AND (&&) - JavaScript - MDN Web Docs
If a value can be converted to true , the value is so-called truthy. If a value can be converted to false ,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found