I want to have two arrays filled with dates. The first one should have those dates in string-format and the second should be the same dates as date-objects.
methods: {
test() {
let employments = [
{ begin: '01.01.2000', end: '01.01.2010' },
{ begin: '01.01.3000', end: '01.01.3010' },
{ begin: '01.01.4000', end: '01.01.4010' }
];
let items = [];
for(let i = 0; i < employments.length; i++) {
items.push(employments[i]);
}
for(let i = 0; i < items.length; i++ ) {
// splitting it up for the correct format
let begin = items[i].begin.split('.').reverse().join('-');
let end = items[i].end.split('.').reverse().join('-');
items[i].begin = new Date(begin);
items[i].end = new Date(end);
}
console.log('items:');
console.log(items);
console.log('this.employments:');
console.log(employments);
}
}
I expected to have two different outputs. One with strings in it and the other one with date objects. What I got instead were two arrays with date objects. And I just don't get why.
I also tried directly giving employments to items (like "let items = employments;" ) instead of doing the push-method, but this didn't work either.
Thanks in advance