Definiendo la clase Punto - Object.create en JavaScript

Clase 12 de 51Fundamentos de JavaScript 2017

Resumen

En JavaScript tenemos varias formas para crear objetos, ahora vamos a crear un nuevo constructor del objeto punto

const Punto = { init: function init(x,y) { this.x = x this.y = y }, moverEnX: function moverEnX(x) { this.x += x }, moverEnY: function moverEnY(y) { this.y += y } } const p1 = Object.create(Punto) p1.init(0,4)