У меня есть этот Coffeescript:
console.log 'TEST'
console.log index
console.log (index is not 0)
console.log (index > 0)
unless index is 0
console.log "passed test"
Это скомпилированный JavaScript:
console.log('TEST');
console.log(index);
console.log(index === !0);
console.log(index > 0);
_results.push(index !== 0 ? console.log("passed test") : void 0);
Это вывод консоли
TEST
0
false
false
passed test
TEST
1
false
true
passed test
Вопрос 1) Почему(index is not 0)
возвращает false
, когда index
равно 1?(index > 0)
возвращает true
для 1, так почему бы (index is not 0)
?
Вопрос 2) Почему тест unless index is 0
проходит, когда index
равен 0?