我试图尝试使用系统来序列化附加数据的函数。
我有这个,但它没有(预)用Node编译,任何人都知道什么是错的?
function outerOuter() {
return (function outer (foo, bar, baz) { // foo, bar, and baz are injected JSON strings
return function yourSerializedFunction () {
//foo, bar, and baz are available here, but you need to call JSON.parse on them
}
}(
'{"foo":"is-serialized"}',
'{"bar":"is-serialized"}',
'{"baz":"is-serialized"}',
));
}
console.log(outerOuter().toString());
如果你能做我想做的事,也许你可以帮助弄清楚出了什么问题:)
答案 0 :(得分:0)
信不信由你,这就是参数列表中的尾随逗号,这有效:
function outerOuter () {
return (function outer (foo, bar, baz) { // foo, bar, and baz are injected JSON strings
return function yourSerializedFunction () {
//foo, bar, and baz are available here, but you need to call JSON.parse on them
}
})(
'{"foo":"is-serialized"}',
'{"bar":"is-serialized"}',
'{"baz":"is-serialized"}'
);
}
console.log(outerOuter.toString());