In a JavaScript object literal, why can’t a method access a sibling method just by its name?
This code:
var doc = {
foldPrompt: function(folded) {
return folded ? "Click to unfold" : "Click to fold"
},
createFoldButtons: function() {
var prompt = foldPrompt(true); //The error is here
$("#ComparisonTable td.secrow").each(function(index, td){
$(td).prepend($('
'));
});
}
}
gives me an error: “Undefined variable: foldPrompt”
What am I doing wrong?