JavaScript setPrototypeOf() method

The Javascript handler setPrototypeOf() method modifies the prototype of an object.

Syntax:

setPrototypeOf: function(target, prototype)

Parameters:
target: It represents the target object.
prototype: It represents the new prototype of the object. It can be null.

Return:
Returns true if the prototype of the object changed successfully otherwise returns false.

Example:

<!DOCTYPE html>
<html>
<body>
<script>
var handler = { abc:45}
var proto = new Proxy(handler, {
setPrototypeOf(a,b) {
return newProto in a;
}
});
document.writeln('Value: ');
document.writeln('abc' in proto);
</script>
</body>
</html>