Skip to content

Instantly share code, notes, and snippets.

@olvap
Last active August 29, 2015 14:03
Show Gist options
  • Select an option

  • Save olvap/75b1ad2f94f64ecf0be3 to your computer and use it in GitHub Desktop.

Select an option

Save olvap/75b1ad2f94f64ecf0be3 to your computer and use it in GitHub Desktop.
A comparation between Coffee and JS
class PahoMessage
constructor: (@message) ->
value: ->
"value: #{ @message }"
topic: ->
"topic: #{ @message }"
paho_message = PahoMessage.new("un mensaje")
console.log paho_message.value
console.log paho_message.topic
var PahoMessage;
PahoMessage = (function() {
function PahoMessage(message) {
this.message = message;
}
PahoMessage.prototype.value = function() {
return "value: " + this.message;
};
PahoMessage.prototype.topic = function() {
return "topic: " + this.message;
};
return PahoMessage;
})();
paho_message = PahoMessage["new"]("un mensaje");
console.log(paho_message.value);
console.log(paho_message.topic);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment