为什么当我向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)
请注意,
时getElementById
给了我for(var foo in Object.getPrototypeOf(document))
(以及其他许多内容),Object.getPrototypeOf(document)
似乎也给了我相同的价值和HTMLDocument
返回for(var foo in HTMLDocument)
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>";
}