Comments on: Truthy & Falsey https://j11y.io/javascript/truthy-falsey/ Sun, 22 Mar 2015 15:39:22 +0000 hourly 1 https://wordpress.org/?v=5.0.13 By: Lee https://j11y.io/javascript/truthy-falsey/#comment-2267 Wed, 03 Oct 2012 15:38:45 +0000 https://j11y.io/?p=1912#comment-2267 Great article.Truthy & Falsey are based on boolean logic. So to
understand truthy & falesy statement completely ,we need to
understand AND, OR and NOT also.

Best example of falsey is :

if (!y)
{
//do something
}

I have a question : Is example given below belongs to Truthy/Falsey or not? I am little confused.

if (y==7)
{
//do something
}

]]>
By: Kaitlyn https://j11y.io/javascript/truthy-falsey/#comment-2266 Wed, 03 Oct 2012 15:26:46 +0000 https://j11y.io/?p=1912#comment-2266 Its worth reading this article. Your this article made my concepts very clear about truthy and falsy equations that used to confuse me earlier but now I can solve these equations by my own and your article helped me a lot to understand these confusing equations. So thanks to you for helping me.

]]>
By: Carter https://j11y.io/javascript/truthy-falsey/#comment-2265 Tue, 18 Sep 2012 16:47:39 +0000 https://j11y.io/?p=1912#comment-2265 I am doing my Bachelors in Computers and studying different programming languages and concepts. Its been always very typical and confusing for me to solve truthy expressions but your article helped me a lot to understand the expression solving. Not only this article but the comments on this article also very good food for truthy-falsey expression solving, So I want to give my thanks to not only the author but to all contributors over here.

]]>
By: Ella Hill https://j11y.io/javascript/truthy-falsey/#comment-2264 Sat, 04 Aug 2012 10:11:25 +0000 https://j11y.io/?p=1912#comment-2264 Interesting blog. Despite its many limitations JS has been very efficacious. The best part is the coding part is very less cumbersome. Thank you so much for the code here. Keep updating with more interesting stuff.

]]>
By: Chris https://j11y.io/javascript/truthy-falsey/#comment-2263 Mon, 25 Jun 2012 17:36:20 +0000 https://j11y.io/?p=1912#comment-2263 Your background is nifty. Could have been done in pure CSS though add some .js and images and it would be very nifty. Very nice site over all…Quick way to learn “truthy”

]]>
By: Sony Santos https://j11y.io/javascript/truthy-falsey/#comment-2262 Wed, 20 Jun 2012 20:05:39 +0000 https://j11y.io/?p=1912#comment-2262 Some unrelated things to say…

1. I have to say that when I saw your name in the title I read “Pseldoy” (as pseudo is falsey).

2. I have found that truthy (and falsey) are adjectives (like true) instead of nouns (like truth). That’s why I arrived at your post. I became sure when I read “the falsey value that you’re looking for”. Thank’s!

3. In Ruby I want to create an object which is falsey, but I can’t. I wish I had a ToBoolean-equivalent method to overload, but I haven’t that AFAIK.

4. Great article! I’ve appreciated it very much! Thank’s again.

5. Great comments, too! 🙂

6. I loved the moving background.

]]>
By: Joe Zim https://j11y.io/javascript/truthy-falsey/#comment-2261 Sun, 08 Jan 2012 00:47:31 +0000 https://j11y.io/?p=1912#comment-2261 It’s amazing the little oddities in JavaScript, which may make it more difficult to program in, but I find it more fun and in many cases it makes programming in JS have less code. The other thing I love about JS is that if I am uncertain of how a conditional will work out, I can just run it in a browser console really quick and have my answer. I suggest this trick for anyone programming in JavaScript. The console is a programmers great little friend.

]]>
By: hotshot309 https://j11y.io/javascript/truthy-falsey/#comment-2260 Tue, 03 Jan 2012 17:30:38 +0000 https://j11y.io/?p=1912#comment-2260 The comments here are just as valuable as the article itself. Thanks to the author and all contributors.

The way I think of it, truthiness/falsiness is determined when evaluating the expression and comparing it to values that could be considered “nothing.” Truth/falsity is determined by looking at whether the expression evaluates to a primitive boolean value exactly, and then comparing its value to true or false. I am still learning about this, but I don’t believe that there is any _implicit_ casting to booleans in JavaScript.

As others have said, the tricky part is that both conditional blocks and variable assignments can both use expressions that are evaluated for truthiness/falsiness (or they can use true/false boolean expressions). Once you really understand that, everything makes a little more sense.

]]>
By: James https://j11y.io/javascript/truthy-falsey/#comment-2259 Mon, 14 Nov 2011 23:55:13 +0000 https://j11y.io/?p=1912#comment-2259 Thanks for the comments!

Jamie and Mathias: excellent point about if(x==true) being different to if(x)!

DZ, new Boolean instantiates a new Boolean object, while Boolean (without the new operator) only casts the value to a boolean (primitive).

From the spec:

15.6.1 The Boolean Constructor Called as a Function
When Boolean is called as a function rather than as a constructor, it performs a type conversion.

new Boolean(true); // <- Calling `Boolean` as a constructor
Boolean(true); // <- Calling `Boolean` as a function
]]>
By: DZ https://j11y.io/javascript/truthy-falsey/#comment-2258 Mon, 14 Nov 2011 23:47:45 +0000 https://j11y.io/?p=1912#comment-2258 You say that “A scarier example is new Boolean(false) which is also truthy!” then at the bottom of the article you say that “Boolean(false); // => false”. Would you mind explaining the difference?

]]>