javascript - Method invocation pattern not working? -
i learning javascript , has called methods:
an example expect work wrote in firefox , did nothing:
var myobject = { value: 0, increment: function (inc) { this.value += inc; } }; console.writeln(myobject.value); var x = myobject.increment(2); console.writeln(x);
what wrong?
1) use console.log
instead of console.writeln
2) have return function. if don't, way value requesting value
var myobject = { value: 0, increment: function (inc) { return this.value += inc; } };
Comments
Post a Comment