A useful method to check if a javascript object evaluates to true
Bower:
bower install isTrue
npm:
npm install istrue --save
Or clone from github:
git clone https://github.com/codeocelot/istrue.git
require("istrue");
<script src="./path/to/main.js" type="text/javascript">
"does this eval to true".isTrue() === true
"".isTrue() === false
Numbers, Arrays & Objects too! (don't forget the paratheses, otherwise js thinks it's a decimal!)
(0).isTrue() === false
(1).isTrue() === true
({}).isTrue() === true // js likes parans around obj/array declarations
([]).isTrue() === true
mocha test.js
I can't think of a future for extentending this simple function. Share your thoughts if you have ideas!