a new syntax to help create objects, using the keyword class
not a full-fledged class based implementation of object oriented paradigm
is just a syntax
//ES5
var SpaceShuttle = function(targetPlanet){
this.targetPlanet = targetPlanet;
}
var zeus = new SpaceShuttle('Jupiter');
//ES6
class SpaceShuttle {//UpperCamelCase name
//creating and initializing an object
//when use new keyward
constructor(targetPlanet) {
this.targetPlanet = targetPlanet;
}
}
const zeus = new SpaceShuttle('Jupiter');
class Vegetable{
constructor(name) {
this.name = name;
}
}
const carrot = new Vegetable('carrot');
console.log(carrot.name);