JavaScript type casting

后端 未结 5 509
无人及你
无人及你 2020-12-03 16:18

Consider empty JavaScript array:

var a = [];
alert(a == false); // shows true
alert(!a); // shows false!

How to explain this? What are the

5条回答
  •  孤城傲影
    2020-12-03 16:54

    Not sure if this answers the question, but there is a new library for getting around all of Javascript's Typecasting weirdnesses:

    Typecast.js

    In a sentence, Typecast solves all the simple problems, so you can focus on the big ones. Typecast fixes what's wrong with Javascript by creating a complete platform for strongly-typed variables in Javascript.

提交回复
热议问题