Created
April 17, 2018 17:59
-
-
Save korzio/0fc17e88626bcc6946186c124be564fe to your computer and use it in GitHub Desktop.
defineProperty.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<meta http-equiv="X-UA-Compatible" content="ie=edge"> | |
<title>Document</title> | |
</head> | |
<body> | |
<script> | |
var obj = {} | |
var x = 0 | |
var descriptor = { | |
configurable: false, | |
// value: 1, | |
// writable: true, | |
get: function() { | |
return x | |
}, | |
set: (a) => { x = x + a } | |
} | |
Object.defineProperty( | |
obj, | |
'prop', | |
descriptor | |
) | |
debugger | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment