I am defining this function in JavaScript and I am getting an error like 'myobj is undefined' in firefox and chrome. How do I define a function argument? Where did i go wrong ? I am not even calling it and I wonder why i am getting an error. JsLint is not showing any error.
function makeBox (myobj) {
if( myobj.fullname.length > 18 ) {
myobj.fullname = myobj.fullname.slice(0 ,15 );
myobj.fullname = myobj.fullname + '...';
}
var box = templates.box.supplant(myobj);
return box;
}
When you call
makeBox, you have to supply it with an object as its argument:Otherwise,
myobjwithin your function will beundefined.