assign() | |
create() | |
defineProperties() | |
defineProperty() | |
entries() | |
freeze() | A frozen object cannot be changed anymore. Compare with isFrozen() |
fromEntries() | |
getOwnPropertyDescriptor() | |
getOwnPropertyDescriptors() | |
getOwnPropertyNames() | |
getOwnPropertySymbols() | |
getPrototypeOf() | The standard way to access an object's prototype. The deprecated and not standard property that stores the object's prototype is __proto__ . Compare with Reflect.getPrototypeOf() . |
hasOwn() | Experimental |
is() | |
isExtensible() | |
isFrozen() | Compare with freeze() |
isSealed() | |
keys() | |
preventExtensions() | |
prototype.__defineGetter__() | Deprecated |
prototype.__defineSetter__() | Deprecated |
prototype.__lookupGetter__() | Deprecated |
prototype.__lookupSetter__() | Deprecated |
prototype.__proto__ | Deprecated in favor of getPrototypeOf() and setPrototypeOf() . |
prototype.constructor | Returns a reference to the Function object that created the instance object. |
prototype.hasOwnProperty() | |
prototype.isPrototypeOf() | |
prototype.propertyIsEnumerable() | |
prototype.toLocaleString() | |
prototype.toSource() | Non-Standard, Deprecated |
prototype.toString() | |
prototype.valueOf() | |
seal() | |
setPrototypeOf() | |
values() |
<!DOCTYPE html> <html> <head> <meta content="text/html;charset=utf-8" http-equiv="Content-Type"> <title>Object.create</title> <script type="text/javascript"> function main() { var out = document.getElementById('out'); var a = { func: function () { out.innerHTML += 'a.func<br>'; }}; var b = { func: function () { out.innerHTML += 'b.func<br>'; }}; var obj_a = Object.create(a); var obj_b = Object.create(b); var obj_c = Object.create(null); obj_a.func(); // a.func obj_b.func(); // b.func // obj_c.func(); // Error: obj_c.func is not a function var obj_d = Object.create({}, {num_ro: {value: 42}, num_w: {value: 42, writable: true}}); out.innerHTML += obj_d.num_ro + '<br>'; // 42 out.innerHTML += obj_d.num_w + '<br>'; // 42 obj_d.num_ro = 100; // won't change 42... obj_d.num_w = 100; // Changes value out.innerHTML += obj_d.num_ro + '<br>'; // 42 (!) out.innerHTML += obj_d.num_w + '<br>'; // 100 } </script> </head> <body onload='main()';> <div id='out'> </div> </body> </html>
<!DOCTYPE html> <html> <head> <meta content="text/html;charset=utf-8" http-equiv="Content-Type"> <title>getOwnPropertyName</title> <script type="text/javascript"> function main() { var obj = {foo: 42, bar: 0}; Object.getOwnPropertyNames(obj).sort().map(function(p) { document.getElementById('out').innerHTML += p + "<br>"; // Own property names are: «foo» and «bar» }); } </script> </head> <body onload='main()';> <div id='out'> </div> </body> </html>
<!DOCTYPE html> <html> <head> <meta content="text/html;charset=utf-8" http-equiv="Content-Type"> <title>__noSuchMethod__</title> <script type="text/javascript"> function main() { var out = document.getElementById('out'); var obj = {}; obj.__noSuchMethod__ = function(func_name, func_args) { out.innerHTML += 'Inexistent function <b>' + func_name + '</b> was called with <i>' + func_args.join(',') + '</i><br>'; } obj.bar = function (func_args) { out.innerHTML += '<b>bar</b> was called with <i>' + func_args + '</i><br>'; } obj.foo(1, 2, 3); // Inexistent function foo was called with 1,2,3 obj.bar('one', 'two', 'three'); // bar was called with one obj.baz('baz'); // Inexistent function baz was called with baz } </script> </head> <body onload='main()';> <div id='out'> </div> </body> </html>