Huauauaa / cheat-sheet

Home Page:https://huauauaa.github.io/cheat-sheet/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

array 空位 empty

Huauauaa opened this issue · comments

commented

数组的空位

数组的空位指的是:数组的某一个位置没有任何值。
如:Array构造函数返回的数组是空位。

  • 注意:空位不是undefined,空位是没有任何值empty.
  • in方法:可以用来于检查某个位置是不是空位,返回布尔值。
  • 注意:forEach,filter,some,every方法都会跳过空位,map方法也会跳过空位,但是也会保留这个值。
  • join()和toString()会将空位视为undefined,而undefined和null会被处理为空字符串。
  • 在ES6中,明确将空位转为undefined

Sent from PPHub