Symbol.unscopables JavaScript

The JavaScript Symbol.unscopables property represents an object whose inherited property names are excluded from with environment bindings. It’s property can be set to true and false. The object would not appear in lexical scope variables if it’s property set to true and it will appear in lexical scope variables if it’s property set to false.

Syntax:

[Symbol.unscopables] 

Parameters:
Object.

Example:

<!DOCTYPE html>
<html>
<body>
<script>    
var display = {a: 1, b: 2};  
display[Symbol.unscopables] = {b: false, a: true};  
with (display) {document.write(b);}   
</script>
</body>
</html>

Output:

2
Please Share