将数据数组传递给jQuery函数

Ben*_*ard 5 arrays jquery function

这是故事......我有一个jQuery函数可以执行某些操作,这个函数经常被引用.其中一个输入参数是一个数组,这个数组数据是硬编码的,因此我想传递这样的数据:(这是我用PHP做的方式)

myFunction(Array("url"=>"abc.com","example"=>"hello_world"));
Run Code Online (Sandbox Code Playgroud)

代替

$arr=Array("url"=>"abc.com","example"=>"hello_world");
myFunction($arr);
Run Code Online (Sandbox Code Playgroud)

那么如何使用我的jQuery函数实现这一点,如果可能的话,我希望这是一个单行程.

编辑

也许我的例子有点误导,再看看数组索引.我发送的数组是一个关联数组.

总之,我不希望在我的函数之前有任何变量,我希望数组直接在函数参数中硬编码,如我给出的第一个例子所示.

:-)

gro*_*ark 7

我重读了您编辑过的问题,您的答案在javascript对象中,就像其他语言的词典或哈希:

    { first_key: '1', second_key: '2', third_key: '3' };
Run Code Online (Sandbox Code Playgroud)

对于你的回调,只需将其作为现场声明的文字传递:

    myFunction({ first_key: '1', second_key: '2', third_key: '3'});
Run Code Online (Sandbox Code Playgroud)