JSFiddle - React, Tailwind, and code Playground

by Roman Zhak

JavaScript

function isNativeFunction(functionSource, functionName) {
    var nativeCodeToString = (function(){
            if (window.opera || typeof /./ === 'function') { // Op Ch fix
                return 'function toString() { [native code] }';
            }
            return 'function toString() {\n    [native code]\n}';
        }()),
        nativeCodeFunction = (function(){
            if (window.opera || typeof /./ === 'function') { // Op Ch fix
                return 'function ' + functionName + '() { [native code] }';
            }
            return 'function ' + functionName + '() {\n    [native code]\n}';
        }()),
        nativeCodeHasOwnProperty = (function(){
            if (window.opera || typeof /./ === 'function') { // Op Ch fix
                return 'function ' + functionName + '() { [native code] }';
            }
            return 'function hasOwnProperty() {\n    [native code]\n}';
        }());

    return (functionSource.toString + '' === nativeCodeToString) &&
    (functionSource.hasOwnProperty + '' === nativeCodeHasOwnProperty) &&
    (functionSource + '' === nativeCodeFunction) &&
    (!functionSource.hasOwnProperty('toString'))  &&
    (Function.prototype.toString + '' === nativeCodeToString)  &&
    (Function.prototype.toString === Function.toString)  &&
    (!Function.prototype.toString.hasOwnProperty('toString'))  &&
    (Object.prototype.toString + '' === nativeCodeToString)  &&
    (!Object.prototype.toString.hasOwnProperty('toString'))  &&
    (typeof Function === 'function')  &&
    (typeof Object === 'function');
};