Skip to content

[总结] JS Tricks 记录一些小技巧 #17

@duyue6002

Description

@duyue6002

判断类型

万能方法

Object.prototype.toString.call(..).slice(8, -1)
原理:返回"[object Null]",后一位永远是正确类型

基本类型 String/Number/Undefined/Boolean

使用 typeof

Array 数组

使用 Array.isArray()instanceof

Null

使用 a === null 判断

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions