Apply & Call

Run Settings
LanguageJavaScript
Language Version
Run Command
function speak(line) { console.log("The " + this.type + " rabbit says '" + line + "'" ); } var whiteRabbit = {type: "gray", speak: speak}; // Simple object method whiteRabbit.speak("Oh my god, how late it's getting"); // apply & call // apply & bind can be used of object.method() // apply & bind methods both take a first argument that can be used to simulate method calls // The first argument is in fact used to give a value to this speak.apply(whiteRabbit, ["Burp"]); speak.call({type: "old"}, "Oh my!");
Editor Settings
Theme
Key bindings
Full width
Lines