value 是什么啊? value 只接收 string 类型的值,所以 value=0 时会把 0 转换为字符串 '0',然后赋值。最终表单的内容是 0。 至于 length 属性: 字符串对 length 赋值,不改变原始串。如果是数组的话,赋值为 0 会清空数组,但是字符串不会。 数组的 length 属性是只读的,在严格模式下,对 length 属性赋值会报类型错误TypeError: 'use strict'; var num = 'aaaaa'; console.log(num.length); num.length = 0; console.log(num); console.log(num.length); 会出错: Uncaught TypeError: Cannot assign to read only property 'length' of string 'aaaaa'
value
是什么啊?value 只接收 string 类型的值,所以 value=0 时会把 0 转换为字符串 '0',然后赋值。最终表单的内容是 0。
至于
length
属性:字符串对
length
赋值,不改变原始串。如果是数组的话,赋值为0
会清空数组,但是字符串不会。数组的
length
属性是只读的,在严格模式下,对length
属性赋值会报类型错误TypeError
:会出错: