这是我的以下代码,
points1 = [{x:'10'},{x:'20',fill:'red'}]
points2 = [{x:'30'},{x:'30'}]
$.extend(true, points1, {}, points2);
返回的点为 [{x:'30'},{x:'30',fill:'red'}] 但我需要的是,如果点2中没有可用的填充,则应该反射(reflect)出来..
我的预期o/p是points1 = [{x:'30'},{x:'30'}]
如何实现?
最佳答案
你们离得很近。只需替换:
$.extend(true, points1, {}, points2);
与:
$.extend(false, points1, {}, points2);
关于javascript - 如何使用jquery扩展对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36217109/