JSFiddle - React, Tailwind, and code Playground

by Alexandre Simoes

JavaScript

function print(text){
	document.body.innerHTML = document.body.innerHTML + text + '<br/>';
}

function myFunction(name, age){
    print('this: ' + this.toString());
    print('name: ' + name);
    print('age: ' + age);
}


print('Simple call');
myFunction('Alex', 38);

print('Using apply');
myFunction.apply(123, ['Older Alex', 55]);

print('Using call');
myFunction.apply({ dumb: true }, ['Younger Alex', 15]);