【发布时间】:2015-10-12 21:36:15
【问题描述】:
假设您在 HTML 中创建了一个文本字段。然后您通过 java 脚本检索用户输入。检索数据时的类型是什么?它会自动成为字符串吗?
<input type="text" id="input">
document.form.name.value; // what is the type of this?
【问题讨论】:
-
除非你转换它,否则它永远是
string。 -
你认为它还能是什么?
-
这也可以是
undefined:)
标签: javascript html types casting