intからBooleanへはよく変換するが、逆のパターンは知らなかったのでメモ。 これが一番いいかも。 var boolValue = true; var intValue = +boolValue; alert(intValue);// 1 が出力される boolValue = false; intValue = +boolValue; alert(intValue);// 0 が出力される 参考にしたページ http://www.solutioncottage.com/ShowSolution.aspx?solID=112 http://www.kawa.net/works/js/learn/basic.html
![JavascriptでBooleanからintへの型変換](https://cdn-ak-scissors.b.st-hatena.com/image/square/8d71ff5111e05619a10d29bb40d7aebaa75c8fbc/height=288;version=1;width=512/https%3A%2F%2Fs0.wp.com%2Fi%2Fblank.jpg)