Skip to content

Instantly share code, notes, and snippets.

@fnogatz
Created August 9, 2015 04:24
Show Gist options
  • Select an option

  • Save fnogatz/3037cf0bebee3e3a3d95 to your computer and use it in GitHub Desktop.

Select an option

Save fnogatz/3037cf0bebee3e3a3d95 to your computer and use it in GitHub Desktop.
var context = (function () {
function fire (str) {
console.log(str)
}
function getFire () {
return fire
}
return {
fire: fire,
getFire: getFire
}
})()
var calls = [
'fire',
'getFire()',
'(getFire())',
'function (str) { getFire()(str) }',
'function (str) { console.log("Hello", str) }',
'function (str) { console.log(some(), str) }',
]
var param = 'World'
// Help needed!
// How do I replace the "with"?
with (context) {
;(function() {
function some() {
return 'Hello'
}
calls.forEach(function (call) {
eval('('+call+')')(param)
})
})()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment