My question Define one object's method as another object's method then use it programmatically has been closed.
I don't understand why this question has been closed. The reason given is "Lack of focus". In the original post, I'm asking one specific question which is why the line cursor.insertText(text).matchArray[i].setFunc();
produces the error. That line is clearly marked with a comment in the code snippet.
I provided further information as to where I was headed with the code once I got past this particular problem in the belief that this would aid the formulation of any answers (perhaps I'm headed down completely the wrong path for what I ultimately want to do).
I've edited the original post (clearly noted) to show what else I've tried to solve the problem (before the question was closed).
The answer to the question lies, I assume, in how I've defined setFunc()
in the matchArray
's objects and that's where I need help. I've been quite focused on that regardless of comments that the code has "several syntax errors" (it doesn't and runs perfectly well with the problematic line commented out).
Also, the title is as focused on the problem as I can make it with the knowledge I have.
What else can I do to get the question reopened?
cursor.insertText(text).matchArray[i].setFunc()
Why doesmatchArray[i]
in this case need to be called on the return ofcursor.insertText(text)
? Why is doing this on two lines unacceptable? What was the goal there?cursor.insertText(text).matchArray[i].setFunc();
should end up being treated as:cursor.insertText(text).setItalic(textStart, textEnd, true);
I've tried settingvar blah = matchArray[i].setFunc();
and thencursor.insertText(text).blah();
but I get 'ReferenceError: setItalic is not defined'