Agregar función para cambiar el nombre de las teclas en un objeto
> var _ = require('underscore');
> var note = {
... '_id': 1,
... 'title': 'Ruby is awesome..',
... 'text': '..and so is CoffeeScript'
... }
> console.log(_.rename(note, [['_id', 'id']]));
{ id: 1,
title: 'Ruby is awesome..',
text: '..and so is CoffeeScript' }
o una matriz de objetos
> var notes = [note, note];
> console.log(_.rename(notes, [['_id', 'id']]));
[ { id: 1,
title: 'Ruby is awesome..',
text: '..and so is CoffeeScript' },
{ id: 1,
title: 'Ruby is awesome..',
text: '..and so is CoffeeScript' } ]
Gracias,
Nisanth
Gracias, pero no gracias, un caso demasiado especial para el subrayado básico. Siéntase libre de mezclarlo para sus propios fines.