Javascript copy object
by Alejandro Hernández
HTML
<div id="res">
no res
</div>
JavaScript
var evento = function() {
//EventoFullCalendar
this.id = -1;
this.title = null;
this.allDay = false;
this.start = null;
this.end = null;
this.url = null;
//UI
this.Empresa = null;
this.Inspector = null;
this.DocumentoAsociado = null;
this.Domicilio = null;
this.Tarea = null;
this.Resultado = null;
this.Comentario = null;
//BO
this.EmpresaID = null;
this.InspectorID = null;
this.DocumentoAsociadoID = null;
}
var source = function() {
//EventoFullCalendar
this.id = -1;
this.title = null;
this.allDay = false;
this.start = null;
this.end = null;
this.url = null;
this.LOCURA = null;
}
var s = new source();
s.id = 8;
s.title = '8';
s.LOCURA = '>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<';
var e = new evento();
e.Empresa = 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA';
Mapear(s,e);
$("#res").html(JSON.stringify(e));
function Mapear(source, target) {
for (var k in source) {
if (target.hasOwnProperty(k))
target[k] = source[k];
}
}