Hacker News new | past | comments | ask | show | jobs | submit login
JavaScript: generating a function with runtime data from a declared function (tsenkov.net)
1 point by tsenkov on March 18, 2014 | hide | past | favorite | 4 comments



I think there are some errors in the final solution code, as it doesn't do what you describe.

Were you aiming at something like this?

var generated = function(value) { return new Function( "return (" + function(valueToSwap) { return { prop: valueToSwap }; } + ")(" + value + ");" ); };


It's called "regression analysis". Nothing to see here, move along. :)


I don't get it, what is?


Using a data set to create a function able to produce that data set.

http://en.wikipedia.org/wiki/Regression_analysis




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: