JSFiddle - React, Tailwind, and code Playground
by lbstr
JavaScript
var data = [{
thumb: '/images/01.png',
title: 'My title',
},{
thumb: '/images/02.png',
title: 'My title',
},{
thumb: '/images/03.png',
title: 'My title',
}];
function changeKeys(data, oldKey, newKey){
for(var i = 0; i < data.length; i++){
if(data[i].hasOwnProperty(oldKey)){
data[i][newKey] = data[i][oldKey];
delete data[i][oldKey];
}
}
}
changeKeys(data, "thumb", "thumbnail");
console.info(data);