JSFiddle - React, Tailwind, and code Playground
by ifandelse
HTML
<script src="https://rawgithub.com/ifandelse/cycloneJS/master/cyclone.js"></script>
JavaScript
var obj = {
city: "Chattanooga",
restaurants: [
{ name: "Urban Stack" },
{ name: "Community Pie" },
{ name: "Milk and Honey" }
]
};
var _val = obj.restaurants[0];
var orig;
// don't ask, just role with me here...
Object.defineProperty(obj.restaurants, "0", {
enumerable: true,
configurable: true,
get: function() {
return _val;
},
set: function(x) {
oldVal = CY.clone(_val);
_val = x;
}
});
window.desc = Object.getOwnPropertyDescriptor(obj.restaurants, "0");
var v = desc.get();
console.log(desc);
console.log(v);
obj.restaurants[0].name = "Taco Mamacita";
$('body').append("<div><pre>" + JSON.stringify(obj, null, 2) + "</pre></div>");
$('body').append("<div>_val: " + JSON.stringify(_val, null, 2) + "</div>");
$('body').append("<div>oldVal: " + JSON.stringify(orig, null, 2) + "</div>");