Last active
August 29, 2015 14:25
-
-
Save yclian/f097595880c9d68e0b54 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Run: `node --harmony car.js` | |
"use strict"; | |
var Car = function(brand) { | |
this.brand = brand; | |
this.vroom = function() { | |
console.log(this.brand + " is slow"); | |
return new Promise(function(f) { | |
console.log(this.brand + " is slow"); f("vroom"); | |
}.bind(this)); | |
}; | |
this.vrooom = () => { | |
console.log(this.brand + " is fast"); | |
return new Promise((f) => { | |
console.log(this.brand + " is fast"); f("vrooom"); | |
}); | |
}; | |
}; | |
var c = new Car("Mazda"); | |
c.vroom().then(function(r) { console.log('Promised: ' + r); }, function(e) { console.log('Broken: ' + e); }); | |
c.vrooom().then(function(r) { console.log('Promised: ' + r); }, function(e) { console.log('Broken: ' + e); }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Expected:
Desired: