Skip to content

Instantly share code, notes, and snippets.

View skymarionsky's full-sized avatar

Yohei Marion Okuyama skymarionsky

View GitHub Profile
@skymarionsky
skymarionsky / bind_polyfill.js
Created May 8, 2014 03:38
IE8以下などでbindが実装されていない場合にbindを追加する
/*
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind
*/
if (!Function.prototype.bind) {
Function.prototype.bind = function (oThis) {
if (typeof this !== "function") {
// closest thing possible to the ECMAScript 5 internal IsCallable function
throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable");
}