- <script language="javascript">
- Function.prototype.bind= function(object){
- var _method=this;
- return function(){
- _method.apply(object,arguments);
- }
- }
- function class1()
- {
- this.attribute="class1";
- this.method=function(){
- alert(this.attribute);
- }
- }
- function class2(){
- }
- class2.prototype={
- attribute:"class2"
- }
- var obj1 = new class1();
- var fun = obj1.method.bind(new class2());
- fun();
- </script>