I'm trying to use eval in HTMLElement's context to mimic event attributes (like onclick) in data attributes with proper context.
Let's have x={}, then this code doesn't work
fx = eval.bind(x);
fx("console.log(this)"); // Window, expected Object
...but this one does:
fn = (function(_){eval(_)}).bind(x);
fn("console.log(this)"); // Object, as expected
Can you explain the differences?