Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

bind - rendition 3 #43

Merged
merged 1 commit into from

2 participants

@iancrowther

1st time contributer

Created a rendition 3 for the bind method

Ian Crowther bind rendition 3
Created a rendition 3 for the bind method
1628fcd
@david-mark david-mark merged commit c19187c into cinsoft:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Aug 1, 2012
  1. bind rendition 3

    Ian Crowther authored
    Created a rendition 3 for the bind method
This page is out of date. Refresh to see the latest.
Showing with 27 additions and 0 deletions.
  1. +27 −0 functions/bind/rendition3.js
View
27 functions/bind/rendition3.js
@@ -0,0 +1,27 @@
+/*global canCall */
+
+/*
+Description:
+Both W3C and MS implementation therefore providing the greatest browser support
+*/
+
+var bind;
+
+if(canCall && Function.prototype.bind){
+ bind = function(fn, thisObject) {
+ return fn.bind.apply(fn, Array.prototype.slice.call(arguments, 1));
+ };
+} else if(canCall && Array.prototype.slice) {
+ bind = function(fn, context) {
+ var prependArgs = Array.prototype.slice.call(arguments, 2);
+
+ if (prependArgs.length) {
+ return function() {
+ fn.apply(context, Array.prototype.concat.apply(prependArgs, arguments));
+ };
+ }
+ return function() {
+ fn.apply(context, arguments);
+ };
+ };
+}
Something went wrong with that request. Please try again.