Alter properties of objects in a function (Javascript) -



Alter properties of objects in a function (Javascript) -

i have declared variable in main html page such:

var colorbuffer;

i pass variable function:

myfunc("example.txt", colorbuffer);

within function property of variable set shown:

function myfunc(file, colbuf) { ... colbuf.items = 4; }

however when refer 'colorbuffer.items' within main html page error 'cannot read property 'items' of undefined'.

so seems using parameter name colbuf not impact argument colorbuffer passed in...how set items property of colorbuffer within function?

many thanks.

setting colorbuffer object resolve this.

var colorbuffer = {};

javascript function parameters

Comments

Popular posts from this blog

javascript - I need to update the text of a paragraph by inline edit -

javascript - THREE.js reposition vertices for RingGeometry -

assembly - What is the addressing mode for ld, add, and rjmp instructions? -