我参与了很多功能,如下面给出的
function a(declara,callback) {
x = declara.x;
y = declara.y;
return callback.call(this,[declara]);
}
a({x:1,y:2},function(){ console.log(x+" , "+y); });
但是我发现这实际上并不是回调的作用,请你解释一下,管道结构如何实现如下:
a({x:1,y:2}).print()
(类似于jQuery的东西,也请我解释一下!)
答案 0 :(得分:1)
如果我已正确理解你的问题,那么
function a(declara) {
x = declara.x;
y = declara.y;
return {print:function(){ console.log(x+" , "+y); }}; //return an object whose one key-value has function inside of it.
}
a({x:1,y:2}).print();