More than 1 year has passed since last update.

他にもありそう。

// type 1
eval('var a=10; alert(a + 7)');

// type 2
new Function('var a=10; alert(a + 7)')();

// type 3
var f = function(){}
f.constructor('var a=10; alert(a + 7)')();

// type 4
location='javascript:var a=10; alert(a + 7)';

new Functionは引数が取れたりして面白い。

var str =  'return x + y';
var f = new Function('x', 'y', str);

f(10, 7); //->17
Sign up for free and join this conversation.
Sign Up
If you already have a Qiita account log in.