Open K0II opened 8 years ago
Object.getOwnPropertyNames(String);
// ["prototype", "toLowerCase", "toUpperCase", "charAt", "charCodeAt", "includes", "contains", "indexOf", "lastIndexOf",
// "startsWith", "endsWith", "trim", "trimLeft", "trimRight", "toLocaleLowerCase", "toLocaleUpperCase", "normalize",
// "match", "search", "replace", "split", "concat", "fromCharCode", "fromCodePoint", "raw", "substring", "substr",
// "slice", "localeCompare", "length", "name"]
Object.getOwnPropertyNames(Number);
// ["prototype", "NaN", "POSITIVE_INFINITY", "NEGATIVE_INFINITY", "MAX_VALUE", "MIN_VALUE", "MAX_SAFE_INTEGER",
// "MIN_SAFE_INTEGER", "EPSILON", "isFinite", "isInteger", "isNaN", "isSafeInteger", "parseInt", "parseFloat",
// "length", "name"]
Object.getOwnPropertyNames(Boolean);
// ["prototype", "length", "name"]
Object.getOwnPropertyNames(Object);
// ["setPrototypeOf", "getOwnPropertyDescriptor", "keys", "is", "defineProperty", "defineProperties", "create",
// "getOwnPropertyNames", "getOwnPropertySymbols", "preventExtensions", "freeze", "isFrozen", "seal", "isSealed",
// "prototype", "assign", "getPrototypeOf", "isExtensible", "length", "name"]
Object.getOwnPropertyNames(Function);
// ["prototype", "length", "name"]
Object.getOwnPropertyNames(Array);
// ["join", "reverse", "sort", "push", "pop", "shift", "unshift", "splice", "concat", "slice", "isArray", "lastIndexOf",
// "indexOf", "forEach", "map", "filter", "every", "some", "reduce", "reduceRight", "from", "of", "prototype", "length", "name"]
Object.getOwnPropertyNames(RegExp);
// ["input", "multiline", "lastMatch", "lastParen", "leftContext", "rightContext", "$1", "$2", "$3", "$4", "$5", "$6", "$7", "$8",
// "$9", "$_", "$*", "$&", "$+", "$`", "$'", "prototype", "length", "name"]
Object.getOwnPropertyNames(Date);
// ["UTC", "parse", "now", "prototype", "length", "name"]
Object.getOwnPropertyNames(Error);
// ["prototype", "length", "name"]
var a = [1,2,3];
Object.getOwnPropertyNames(a); // ["0", "1", "2", "length"]
'toString' in a; // true
'prototype' in a; // false
'constructor' in a; // true
a.constructor; // Array()
a.constructor.toString();
// function Array() {
// [native code]
// }
toString
和constructor
都是向上查找原型链时找到的属性
注:将a替换成new调用生成的数组对象结果是一样的
九个内置对象(函数)原型的property