Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
Sign upThe Function constructor is eval #211
Comments
This comment has been minimized.
This comment has been minimized.
julien-f
commented
Jul 29, 2015
|
I don't understand your need, why not simply create a regular function? function fn (param) {
param.sum = param.a + param.b
return param
}
var res = fn({a: 1, b: 2})
assert(res.sum, 3) |
This comment has been minimized.
This comment has been minimized.
|
Because code is generated. I need eval or new Function. I'm choosing for new Function because eval expose all my context. |
This comment has been minimized.
This comment has been minimized.
julien-f
commented
Jul 29, 2015
|
Standard is based on ESLint and there is a way to ignore some warnings, check in the README. |
This comment has been minimized.
This comment has been minimized.
|
Ok @julien-f , thanks. I will disable in my code. But what do you think? If it's necessary parse a generated code why use eval? Eval expose all scope to the evaluated code, it's not safe. |
thr0w
closed this
Jul 29, 2015
This comment has been minimized.
This comment has been minimized.
julien-f
commented
Jul 29, 2015
|
I am not sure I understand your question :p It is probably indeed better to use |
This comment has been minimized.
This comment has been minimized.
|
ok. Sorry. It's explained here. Thank you |
This comment has been minimized.
This comment has been minimized.
|
@thr0w you might be interested in https://github.com/mafintosh/generate-function |
thr0w commentedJul 29, 2015
I'm using Function constructor because need pass parameters to code. But standard not accept it.
What you suggest to do?