C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML
JavaScript handler.getPrototypeOf() MethodThe handler.getPrototypeOf() method is a trap for the internal method. If target is not extensible, then this method returns the same value as Object.getPrototypeOf(target). SyntaxgetPrototypeOf(target) Parameterstarget: The target object. Return valueThis method returns an object or null. Browser Support
Example 1const obj = {}; const proto = {}; const hag = { getPrototypeOf(target) { document.writeln (target === obj); document.writeln (this === hag); return proto; } }; const p = new Proxy(obj, hag); document.writeln(Object.getPrototypeOf(p) === proto); Output: true true true Example 2var obj = {}; var p = new Proxy(obj, { getPrototypeOf(target) { return Array.prototype; } }); document.write( p instanceof Array ); Output: true Example 3const Prototype = { eyeCount : 32 }; const handler = { getPrototypeOf(target) { return Prototype; } }; const obj = new Proxy(Prototype, handler); document.writeln(Object.getPrototypeOf(obj) == Prototype); Output: true
Next TopicJavaScript handler
|