Published unlisted
Edited
Jun 13, 2018
Insert cell
Insert cell
attr = {
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'

return attr;
}
Insert cell
attr.myprop
Insert cell
attr.nonexistentprop
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more