• in操作符


    // Arrays,数组:下标 in array,length也可以

    var trees = new Array("redwood", "bay", "cedar", "oak", "maple");

    0 in trees        // returns true

    3 in trees        // returns true

    6 in trees        // returns false

    "bay" in trees    // returns false (you must specify the 

                      // index number, not the value at that index)

    "length" in trees // returns true (length is an Array property)

     

    // Predefined objects:内置对象

    "PI" in Math          // returns true

     

    // Custom objects:对象,key in obj

    var mycar = {make: "Honda", model: "Accord", year: 1998};

    "make" in mycar  // returns true

    "model" in mycar // returns true

     

    //使用字符串对象构造的

    var color1 = new String("green");

    "length" in color1 // returns true 

    //string不会使用构造函数转换

    var color2 = "coral";

    // generates an error (color2 is not a String object)

    "length" in color2

     

    //delete之后,就false了

    var mycar = {make: "Honda", model: "Accord", year: 1998};

    delete mycar.make;

    "make" in mycar;  // returns false 

    var trees = new Array("redwood", "bay", "cedar", "oak", "maple");

    delete trees[3];

    3 in trees; // returns false

     

    //设为undefined的话,就false

    var mycar = {make: "Honda", model: "Accord", year: 1998};

    mycar.make = undefined;

    "make" in mycar;  // returns true 

    var trees = new Array("redwood", "bay", "cedar", "oak", "maple");

    trees[3] = undefined;

    3 in trees; // returns true

     

    //可以找到原型链的key

    "toString" in {}; // returns true

  • 相关阅读:
    跟着百度学PHP[6]超级全局变量
    DuBrute 3.1
    第三方提权之serv-u提权
    报错注入分析之Extractvalue分析
    报错注入分析之updatexml注入
    B/S与C/S架构
    Python IDLE背景设置与使用
    调试软件的基本方法
    Windows10下安装python(配置环境变量)
    磁盘分区
  • 原文地址:https://www.cnblogs.com/wang-jing/p/4736436.html
Copyright © 2020-2023  润新知