Is it possible to execute some code every time the object has changed?
var a = {x: 12, y: 63}; a.watch(function () { console.log('The object has changed!'); }); a.x = 16; // The object has changed! a.y = 1; // The object has changed!
It seems to be available only for Firefox: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/watch
How can this be achieved in JavaScript / node.js? (if possible, without using the getter / setter method)
You can use Object Observe ... this is experimental, so proceed with caution ...
var obj = { foo: 0, bar: 1 }; Object.observe(obj, function(changes) { console.log(changes); }); obj.baz = 2;
Source: https://habr.com/ru/post/1568729/More articles:What is the most efficient way to extract an arbitrary range of bits from a continuous sequence of words? - c ++.htaccess routing to a subdirectory on the server? work / download times - httpTest automation application Silverlight: MS Test Manager vs Selenium - seleniumCrashlytics Integrated Kit failed with Android project - androidTalend - combine two lines into one - talendWhat is the relationship between canvas and matrix in Android? - androidhttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1568731/looping-through-9000-individual-pov-files-to-create-9000-individual-png&usg=ALkJrhhF7akrEAqqweLOH2sUFcrPc7VRlAWhen to use implicit wait and where to use - seleniumRendering multiple files in POV-Ray (Windows) - fileFinding a key value from a nested hash array in a ruby ββ- arraysAll Articles