JSFiddle - React, Tailwind, and code Playground
HTML
<!DOCTYPE html>
<meta charset="utf-8">
<body>
<script>
var handler = {
get: function(obj, prop) {
if (prop in obj) {
return obj[prop];
} else {
throw `Unknown property '${prop}'`; // remove this line and it works
}
}
};
var attr = new Proxy({}, handler);
//var attr = {}; // use this line instead and it works
attr.myprop = 'Hello World'
console.log('attr.myprop');
</script>