最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Is there a function in javascript similar to compact from php? - Stack Overflow

programmeradmin2浏览0评论

I found pact function very useful (in php). Here is what it does:

$some_var = 'value';
$ar = pact('some_var');
//now $ar is array('some_var' => 'value') 

So it create array from variables which you specify, when key for elements is variable name. Is there any kind of function in javascript ?

I found pact function very useful (in php). Here is what it does:

$some_var = 'value';
$ar = pact('some_var');
//now $ar is array('some_var' => 'value') 

So it create array from variables which you specify, when key for elements is variable name. Is there any kind of function in javascript ?

Share Improve this question asked Apr 29, 2013 at 3:22 kirugankirugan 2,6243 gold badges24 silver badges41 bronze badges 3
  • Please consider changing the accepted answer to stackoverflow./a/45884534/6047611 – A. L. Strine Commented Dec 6, 2019 at 0:36
  • Done. But it seems unusual on stackoverflow to change accepted answer after 4 years. – kirugan Commented Dec 6, 2019 at 17:06
  • Thank you, this will help the next person who finds this post
发布评论

评论列表(0)

  1. 暂无评论