JSFiddle - React, Tailwind, and code Playground
by rich_harris
JavaScript
Function.prototype.constructor = function () {
return Function.apply(null, arguments);
};
if ( statementIsSafe() ) {
1..constructor.constructor('alert(1)')();
}
// evaluator evaluates each node in AST, makes sure it's
// not `Function`, before allowing it to be executed -
// essentially a longer version of this
function statementIsSafe () {
return 1..constructor.constructor !== Function;
}