Google News
logo
CoffeeScript - Interview Questions
What is Prototypal Inheritance in CoffeeScript?
In addition to supporting ES2015 classes, CoffeeScript provides a shortcut for working with prototypes. The :: operator gives you quick access to an object’s prototype :
String::dasherize = ->
  this.replace /_/g, "-"
​
String.prototype.dasherize = function() {
  return this.replace(/_/g, "-");
};
Advertisement