JSFiddle - React, Tailwind, and code Playground

by polshgiant

JavaScript

function applyCall(arr, fn) {
    document.write('typeof array element in applyCall: ' + typeof arr[0] + '<br /><br />');
    fn.call(arr[0], 0, arr[0]);
}

function test() {
    var arr1 = ['blah'];
    applyCall(arr1, function (i, val) {
        document.write('this === val: ' + (this === val) + ' (why isn\'t this true?)<br />');
        document.write('typeof this in test: ' + typeof this + ' (why isn\'t this string?)<br />');
        document.write('typeof val in test: ' + typeof val + '<br />');
    });
}

test();