Are the following two constructions identical, or are there any differences between them?
let x = new Item(v1, v2, ...)
And:
let x = Object.create(Item.prototype)
x.constructor(v1, v2, ...)
The code I was writing to see which one to use is the following (though for academic purposes):
'use strict';
function Meal(type) {
this.type = type;
};
Meal.isMeal = function(obj) {console.log(obj instanceof Meal)};
Meal.prototype.eat = function() {console.log(`${this.type} has been eaten!`)};
// let breakfast = new Meal('Breakfast');
let breakfast = Object.create(Meal.prototype);
breakfast.constructor('Breakfast')
Meal.isMeal(breakfast);
breakfast.eat();