Scripter Javascript Tutorial
javascriptmusiclogicscripterbookexcerpttutorial33 instanceof
comparison
The instanceof
comparison returns true if an object is
an instance of a particular object type.
function HandleMIDI(event) {
if ( event instanceof NoteOn ) {
Trace("NoteOn");
} }
In the above example:
Line 1: A MIDI event is passed into the
HandleMIDI()
function.Line 2: The
instanceof
comparison is used to determine whether or not the event isNoteOn
.Line 3: If the event is a
NoteOn
, then the script does something with that event. Otherwise, the event is ignored.