JavaScript data types and detection

JavaScript: Abbreviation-js is a literal scripting language and one of the core technologies of the World Wide Web

One: What are the data types of js

JS data types are divided into two types: simple data types and complex data types

Simple data types: string, number, boolean, null, undefined, symbol, Bigint

Complex data types: object (function, array, object)

Two: data type characteristics

Simple data types: data stored directly on the stack

Complex data types: reference addresses are stored on the stack, and real data addresses are stored on the heap

Three: Data type detection method

typeof: Only basic data types can be detected --- the return value is a data type

instanceof: can only detect whether it is a reference data type --- the return value is true or false

constructor: basically can detect all data types except null and undefined

Object.prototype.toString.call: in call (data value is data type)

Array.isArray(): only used to detect whether it is an array

Guess you like

Origin blog.csdn.net/weixin_71171795/article/details/129199051