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

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

vowpalwabbit - Interpreting Vowpal Wabbit results: Why are some lines appended by "h"? -

Is there a way to convert an HTML page styled with Bootstrap CSS into email-compatible html? -