Skip to content

Instantly share code, notes, and snippets.

Created Jun 8, 2018
What would you like to do?
ES6 Classes
//this is the old way of creating a class using protypal inheritance.
//As you see this is somewhat cumbersome and difficult to follow
var Employee = function(){
//Assign the do work method to the Employee object.
Employee.prototype ={
doWork: function(){
return "complete";
//create a new employee using our Employee class.
var e = new Employee();
//How does ES6 do this?
//look below. Just realize that they are doing the same thing,
//however ES6 has the syntactic sugar to make this much cleaner
class Employee{
return "more work being done";
var e2 = new Employee();
//much cleaner approach and has more of an object oriented feel. Muh feelz!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment