Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/387.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 管道功能_Javascript_Jquery_Pipeline - Fatal编程技术网

Javascript 管道功能

Javascript 管道功能,javascript,jquery,pipeline,Javascript,Jquery,Pipeline,我研究了很多函数,如下所示 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); }); 但我发现callback实际上并不是这么做的,请您解释一下,管道结构是如何实现的,如下所示: a({x:1,y:2}).print() (类似

我研究了很多函数,如下所示

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); });
但我发现callback实际上并不是这么做的,请您解释一下,管道结构是如何实现的,如下所示:

a({x:1,y:2}).print()

(类似于jQuery的功能,也请解释一下!)

如果我正确理解了您的问题,那么

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();

最好删除
回调
参数