我有两个长度相同的数组。
array1 = ['title', 'details', 'price', 'discount'];
array2 = ['product name', 'product details', 200, 20];
Run Code Online (Sandbox Code Playgroud)
想要将它们转换为一个对象,如下所示
newObject = {
title: 'product name',
details: 'product details',
price: 200,
discount: 20
}
Run Code Online (Sandbox Code Playgroud)
怎么做?
javascript ×1