Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
JavaScript illustrates that methods are the same as functions with an implicit parameter "this"
var completeSale = function(num) {
console.log("Sale " + num + ": selling " + this.items + " to " + this.customer);
var foo = {
customer: "Fred",
items: ["carrot","eggs"],
complete: completeSale
console.log("method style:")
console.log("function style:"), 100)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment