利用Object.prototype.toString.call(val)判断数据类型

xiaoxiao2022-06-11  30

利用Object.prototype.toString.call(val)判断数据类型

返回值会以下列形式返回:

1. null => "[object Null]" 2. undefined => "[object Undefined]" 3. true => "[object Boolean]" 4. 1 => "[object Number]" 5. '' => "[object String]" 6. [] => "[object Array]" 7. {} => "[object Object]" 8. function () {} => "[object Function]" 9. new Date() => "[object Date]" 10. /./ => "[object RegExp]" 11. Math => "[object Math]" 12. Math.max() => "[object Number]"
转载请注明原文地址: https://www.6miu.com/read-4930383.html

最新回复(0)