Skip to content

Instantly share code, notes, and snippets.

@korzio
Created April 17, 2018 17:59
Show Gist options
  • Save korzio/0fc17e88626bcc6946186c124be564fe to your computer and use it in GitHub Desktop.
Save korzio/0fc17e88626bcc6946186c124be564fe to your computer and use it in GitHub Desktop.
defineProperty.html
<!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