我有一个数组,我想为不同的值制作不同的数组。这是我的数组
var data = [{
"rateType": "Fixed",
"interestRateMin": "12.0",
"imageUrl": "\/images\/dyn\/null.jpg",
"financingPercentageMax": "80",
"interestRateMax": "12.0",
"prePaymentCharge": "Nil",
"financingPercentageMin": "60",
"bankName": "Muthoot Finance",
"security": "Pledge of the gold ornaments and coins.",
"repaymentTenureInYears": "0.25",
"age": "35",
"processingFee": "Nil",
"maxLoanAmt": "10000000"
}, {
"rateType": "Floating",
"interestRateMin": "12.5",
"imageUrl": "\/images\/dyn\/94.jpg",
"financingPercentageMax": "90",
"interestRateMax": "12.5",
"prePaymentCharge": "DNA",
"financingPercentageMin": "75",
"bankName": "Federal Bank- Gold loan",
"security": "DNA",
"repaymentTenureInYears": "1",
"age": "35",
"processingFee": "DNA",
"maxLoanAmt": "7500000"
}, {
"rateType": "Floating",
"interestRateMin": "13.0",
"imageUrl": "\/images\/dyn\/155.jpg",
"financingPercentageMax": "80",
"interestRateMax": "13.0",
"prePaymentCharge": "DNA",
"financingPercentageMin": "80",
"bankName": "State Bank of Travancore- Liquid loan",
"security": "Pledge of gold ornaments",
"repaymentTenureInYears": "1",
"age": "35",
"processingFee": "DNA",
"maxLoanAmt": "1000000"
}, {
"rateType": "Floating",
"interestRateMin": "13.25",
"imageUrl": "\/images\/dyn\/151.jpg",
"financingPercentageMax": "80",
"interestRateMax": "13.25",
"prePaymentCharge": "DNA",
"financingPercentageMin": "80",
"bankName": "State Bank Of Hyderabad- Overdraft",
"security": "Pledge of Gold ornaments or Jewellery made of 22 Carat or 18 Carat",
"repaymentTenureInYears": "3",
"age": "35",
"processingFee": "1.10% of the original limit or max Rs 330",
"maxLoanAmt": "1500000"
}, {
"rateType": "Floating",
"interestRateMin": "14.5",
"imageUrl": "\/images\/dyn\/161.jpg",
"financingPercentageMax": "80",
"interestRateMax": "14.5",
"prePaymentCharge": "DNA",
"financingPercentageMin": "80",
"bankName": "Lakshmi Vilas Bank",
"security": "Pledge of gold ornaments",
"repaymentTenureInYears": "1",
"age": "35",
"processingFee": "0.50% of the limit sanctioned, min Rs 100",
"maxLoanAmt": "5000000"
}];
我想将所有rateType存储在一个数组中。像这样我想制作不同的数组来存储其他元素。有人可以指导我吗
答案 0 :(得分:1)
如果要在data
对象中获取var data=[{rateType:"Fixed",interestRateMin:"12.0",imageUrl:"/images/dyn/null.jpg",financingPercentageMax:"80",interestRateMax:"12.0",prePaymentCharge:"Nil",financingPercentageMin:"60",bankName:"Muthoot Finance",security:"Pledge of the gold ornaments and coins.",repaymentTenureInYears:"0.25",age:"35",processingFee:"Nil",maxLoanAmt:"10000000"},{rateType:"Floating",interestRateMin:"12.5",imageUrl:"/images/dyn/94.jpg",financingPercentageMax:"90",interestRateMax:"12.5",prePaymentCharge:"DNA",financingPercentageMin:"75",bankName:"Federal Bank- Gold loan",security:"DNA",repaymentTenureInYears:"1",age:"35",processingFee:"DNA",maxLoanAmt:"7500000"},{rateType:"Floating",interestRateMin:"13.0",imageUrl:"/images/dyn/155.jpg",financingPercentageMax:"80",interestRateMax:"13.0",prePaymentCharge:"DNA",financingPercentageMin:"80",bankName:"State Bank of Travancore- Liquid loan",security:"Pledge of gold ornaments",repaymentTenureInYears:"1",age:"35",processingFee:"DNA",maxLoanAmt:"1000000"},{rateType:"Floating",interestRateMin:"13.25",imageUrl:"/images/dyn/151.jpg",financingPercentageMax:"80",interestRateMax:"13.25",prePaymentCharge:"DNA",financingPercentageMin:"80",bankName:"State Bank Of Hyderabad- Overdraft",security:"Pledge of Gold ornaments or Jewellery made of 22 Carat or 18 Carat",repaymentTenureInYears:"3",age:"35",processingFee:"1.10% of the original limit or max Rs 330",maxLoanAmt:"1500000"},{rateType:"Floating",interestRateMin:"14.5",imageUrl:"/images/dyn/161.jpg",financingPercentageMax:"80",interestRateMax:"14.5",prePaymentCharge:"DNA",financingPercentageMin:"80",bankName:"Lakshmi Vilas Bank",security:"Pledge of gold ornaments",repaymentTenureInYears:"1",age:"35",processingFee:"0.50% of the limit sanctioned, min Rs 100",maxLoanAmt:"5000000"}];
var result = [];
data.forEach(function(element){
this.push(element.rateType);
}, result);
console.log(result);
的数组(例如),可以执行以下操作:
thisArg

我已使用forEach
方法的<script>
var end = new Date('2016-10-26 00:00:00');
var _second = 1000;
var _minute = _second * 60;
var _hour = _minute * 60;
var _day = _hour * 24;
var timer;
function showRemaining() {
var now = new Date();
var distance = end - now;
if (distance < 0) {
clearInterval(timer);
document.getElementById('countdown').innerHTML = 'EXPIRED!';
return;
}
var days = Math.floor(distance / _day);
var hours = Math.floor((distance % _day) / _hour);
var minutes = Math.floor((distance % _hour) / _minute);
var seconds = Math.floor((distance % _minute) / _second);
document.getElementById('countdown').innerHTML = days + 'days ';
document.getElementById('countdown').innerHTML += hours + 'hrs ';
document.getElementById('countdown').innerHTML += minutes + 'mins';
document.getElementById('countdown').innerHTML += seconds + 'secs';
}
timer = setInterval(showRemaining, 1000);
</script>
<div id="countdown"></div>
来创建新数组。
干杯!