标签:基本数据 new fun cti 作用 prototype 一个 字符串 on()
let str = ‘{}‘; let fn = function(){}; let obj = {}; let ary = []; let rg = /\d/; console.log(typeof str);//string console.log(typeof fn);//function console.log(typeof obj);//object console.log(typeof ary);//object console.log(typeof rg);//object
let arr = [1,2,3]; console.log(arr instanceof Array);//true 检测arr是不是内置类Array的实例
function fns (){} let f = new fns; console.log(f.constructor === fns);//true console.log(f.constructor.name);//fns构造函数名称
//constructor属性并非一定指向构造函数,他也可以修改、变更
let date = new Date; console.log(Object.prototype.toString.call(date));//[object Date] let re = ‘/\d+g/‘; console.log(Object.prototype.toString.call(re));//[object String] let sz = [2,3,4]; console.log(Object.prototype.toString.call(sz));//[object Array] let hs = function(){}; console.log(Object.prototype.toString.call(hs));//[object Function]
标签:基本数据 new fun cti 作用 prototype 一个 字符串 on()
原文地址:https://www.cnblogs.com/theblogs/p/9940345.html