javascript - typeof 2D 数组将变为 String。为什么?
问题描述
- 我有一些看起来像二维数组的东西。
typeof
某些数组将始终返回一个object
.- 那么,为什么在下面的示例中,返回类型是
string
?
<script>
var x = [typeof x, typeof y][1];
console.log(typeof x);
</script>
解决方案
[typeof x, typeof y]
评估为["undefined", "undefined"]
。[typeof x, typeof y][1]
评估为"undefined"
。
推荐阅读
- c# - C# 检查和调用可能存在或不存在的对象属性
- android - MediaStore.Images.Thumbnails.getThumbnail 返回 null
- python - 如何编写 python 程序计算 n+nn+nnn+nnnn+... nn...n 的值 ntimes 给定的数字作为 n 的值
- java - 用按钮链接气泡选择器中的气泡
- python - 为什么 df.cumsum() 给出 ValueError: Wrong number of items passed, placement 意味着 1
- performance - 了解elasticsearch慢查询日志格式
- arrays - 如何在汇编语言中切换数组的第一个和第二个、第三个和第四个等元素并以 dec 输出?
- javascript - 反应钩子useState不能存储json或字符串
- python - 我将图片转换为 GIF,但海龟的 bgpic() 仍然无法正常工作
- .net - 使用 moq 在 xunit 中更新操作