---
title: "Functionbind"
author: "rockyuse"
date: "2013-05-28T11:07:29Z"
tags: []
categories: ["Web前端"]
slug: "functionbind"
draft: false
lastmod: "2013-05-28T11:07:29Z"
id: 1878715
url: "https://rockyuse.iteye.com/blog/1878715"
---

```
Function.prototype.bind = function () {
	var __method = this;

	var args = Array.prototype.slice.call(arguments);
	var object = args.shift();
	return function () {
		__method.apply(object, args.concat(Array.prototype.slice.call(arguments)));
	}
}

var obj = {
	name: 'franky'
},
fn = function (a, b, c, d, e) {
	console.log([this.name, a, b, c, d, e]);
}.bind(obj, 1, 2, 3)

fn(4, 5); // franky,1,2,3,4,5
```