Skip to content

Instantly share code, notes, and snippets.

@droxer
Created June 2, 2015 13:11
Show Gist options
  • Save droxer/3d40dc5a3fd581a0214d to your computer and use it in GitHub Desktop.
Save droxer/3d40dc5a3fd581a0214d to your computer and use it in GitHub Desktop.
javascript bind example.
#!/usr/local/bin/node
var assert = require("assert")
function talk (who) {
return this.name + " is talking with " + who
}
var michael = {
name : "michael"
}
var binded = talk.bind(michael, "Sam")
assert.equal(binded(), "michael is talking with Sam")
assert.equal(talk.call(michael, "Sam"), "michael is talking with Sam");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment