JS: var a = {"Client":"jQuery","Server":"PHP"}; var b = a; a["New"] = "Element"; console.log(b); // 输出 Object { Client="jQuery", Server="PHP", New="Element"} PHP例程1: $a = array('Client'=>'jQuery','Server'=>'PHP'); $b = $a; $a['New'] = 'Element'; var_export($b); //输出 array('Client'=>'jQuery','Server'=>'PHP') PHP例程2: $a = array('Client'=>'jQuery','Server'=>'PHP'); $b = &$a; //引用赋值 $a['New'] = 'Element'; var_export($b); //输出 array('Client'=>'jQuery','Server'=>'PHP','New'=>'Element')
JavaScript中把一个关联数组a赋值给b,然后改变a的内容,为什么b也跟着发生变化?
繁星淼淼
相关分类