Skip to content

我要懂系列-基本类型和引用类型 #27

@shaodahong

Description

@shaodahong

前言

回头来看基础总会有不一样的感受,所以弄了个系列记录下,这篇算是起点,共勉

JS 是门弱类型语言,包含两种类型

  • 基本类型
  • 引用类型

先来说说基本类型,基本类型包含

  • string
  • number
  • boolean
  • undefined
  • null
  • symbol
  • bigint

引用类型包含

  • object
  • function
  • array
  • map
  • set

基本类型也叫简单类型或者值类型,我们可以使用 typeof 来得到它的类型

typeof '1'
// "string"

typeof 1
// "number"

typeof true
// "boolean"

typeof undefined
// "undefined"

typeof null
// "object"

typeof Symbol()
// "symbol"

typeof 1n
// "bigint"

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions