In many of the scripts here in this forum you will find code like the following:
for (var i in object) {
console.log("{0}", i);
// do something else with i or object[i]
}
The code iterates over all properties of a given object and does something with that knowledge, e.g. "search for a given property". Not so often seen but similar code is this one:
Object.keys(object).forEach(function (i) {
console.log("{0}", i);
// do something else with i or object[i]
});
If you run both on the same object, you will get slightly different results: the for..in loop provides you more properties then the Object.keys. Why is that so?
Well, the answer is well explained in this article:
Object.keys() returns an array whose elements are strings corresponding to the enumerable string-keyed property names found directly upon object. This is the same as iterating with a for...in loop, except that a for...in loop enumerates properties in the prototype chain as well.
That statement reveals it: in medini we return the metaclass of any model object as prototype, hence for..in will also return the properties of the metaclass. That's not absolutely in line with Java Script and we decided to remove that feature in a future version.
Is there any consequence for you? Maybe. You should in any case replace constructs like:
if (object.prototype == Metamodel.x.y)
by
if (object instanceof Metamodel.x.y)
If you have any comment on the planned change or question related to the above two constructs, don't hesitate to ask here in this article.
Happy Scripting
Jan