Object.keys(文档)中没有函数

时间:2017-03-23 13:36:46

标签: javascript

为什么当我向function添加object时,它是Object.keys(myObj)的一部分,而对于例如document.getElementById则不然。 Object.keys(document)var myObj = {} myObj.text = "hi" myObj.func = function(){} console.log(Object.keys(myObj)) console.log(Object.keys(document)) console.log(typeof myObj) console.log(typeof document) console.log(typeof myObj.func) console.log(typeof document.getElementById)

for(var foo in document)

请注意,

  1. getElementById给了我for(var foo in Object.getPrototypeOf(document))(以及其他许多内容),
  2. Object.getPrototypeOf(document)似乎也给了我相同的价值和
  3. HTMLDocument返回for(var foo in HTMLDocument)
  4. Object.keys(Node)只是给了我Object.getPrototypeOf(HTMLDocument) Node var resArr = [] for(var foo in document) resArr.push(foo) console.log("results (var foo in document): " + resArr.length) var resArr = [] for(var foo in Object.getPrototypeOf(document)) resArr.push(foo) console.log("results (var foo in Object.getPrototypeOf(document)): " + resArr.length) var resArr = [] for(var foo in HTMLDocument) resArr.push(foo) console.log("results (var foo in HTMLDocument): " + resArr.length) console.log("Object.getPrototypeOf(document): " + Object.getPrototypeOf(document)) console.log("Object.getPrototypeOf(document) === HTMLDocument: " + (Object.getPrototypeOf(document) === HTMLDocument)) console.log("Object.getPrototypeOf(document) == HTMLDocument: " + (Object.getPrototypeOf(document) == HTMLDocument)) console.log("Object.getPrototypeOf(document) instanceof HTMLDocument: " + (Object.getPrototypeOf(document) instanceof HTMLDocument))}的内容:

    Object.getOwnPropertyNames(document)

    另请注意,与Bergi建议的相反,将此标记为22658488 getElementById的副本不会返回这些其他成员(如console.log(Object.getOwnPropertyNames(document))):

        switch(true){
    
        case($passwords[$key] != $password):
            echo "The username and/or password is incorrect<br>";
        case(strlen($username) < 4 || strlen($username) > 10):
            echo "The username must be between 4-10 characters<br>";
        case(strlen($password) < 4):
            echo "The password must be at least 4 characters<br>";            
        case(1>2):
            echo $username . " " . $password . " " . strlen($username) . " " . strlen($password);
            break;
    
        default:
            echo "Login Success<br>";
    }
    

0 个答案:

没有答案