I do not understand why the feature does not work , I passed into the method foreach.
var methods = {
foreach: function(f){
for(var i = 0; i <= this.x; i++){
f(i);
}
}
};
function test(x) {
var t = Object.create(methods);
t.x = x;
return t;
};
var t = test(10);
console.log(t.x); //10
t.foreach(console.log()); //Uncaught TypeError: undefined is not a function
Thx!