Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Yeah, "!!variable" works, and in my case I used ".length > 0". Boolean(variable) works too. It's just unfortunate when you're assuming that the expression or typecasting works like in JavaScript, and then AngularJS had to invent these unnecessary rules that make no sense. JavaScript's type coercion is tricky enough, you don't need to make it worse.


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: