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

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -