js六大数据类型:number、string、object、Boolean、null、undefined

hasOwnProperty (查询某个方法是否属于其对象);

例: var n = new Array();

Array.prototype.num2 = 1;

n.num = 1;

n.hasOwnProperty("num"); true;

n.hasOwnProperty("num2"); false; 因为不属于其直接函数,属于所有数组的共同对象Array

constructor  测试此函数是哪个函数的对象(每一个函数都会有,在创建的时候自动生成的)

例:var n = [];

console.log(n.constructor == Array); true

 Array.prototype.name = "小明";

Array.prototype.age = 1;

Array.prototype = {

name : "小明",

age : 1

}

上面两种写法是一样的,但是下面的写法会导致 constructor 指示异常,下面的写法,一般要修正指向

例如

Array.prototype = {

constructor : Array,

name : "小明",

age : 1

}

需要常记的内容\

toString

需要常记的内容

 类型判断

var a = [];

Object.prototype.toString.call(a); //[Object Array]

a = null 结果是 [Object null]

a = {} 结果是  [Object Object]

 需要常记的内容

 

相关文章:

  • 2021-10-25
  • 2021-05-05
  • 2021-12-30
  • 2022-12-23
  • 2022-12-23
  • 2022-01-02
  • 2021-11-26
猜你喜欢
  • 2022-12-23
  • 2021-04-28
  • 2022-12-23
  • 2021-06-27
  • 2021-06-12
  • 2021-08-19
  • 2021-08-23
相关资源
相似解决方案