plastikaweb
9/4/2017 - 6:10 PM

JS Bin explicit this binding in js / / source http://jsbin.com/qicehok

JS Bin explicit this binding in js / / source http://jsbin.com/qicehok

<!DOCTYPE html>
<html>
<head>
<meta name="description" content="explicit this binding in js">
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>JS Bin</title>
</head>
<body>

<script id="jsbin-javascript">
'use strict';
function foo() {
  console.log(this.bar);
}

var obj = {bar: 'bar'};
var obj2 = {bar: 'bar2'};

var orig = foo;
foo = function() {
  orig.call(obj);
}

foo();
foo.call(obj2);
</script>



<script id="jsbin-source-javascript" type="text/javascript">'use strict';
function foo() {
  console.log(this.bar);
}

var obj = {bar: 'bar'};
var obj2 = {bar: 'bar2'};

var orig = foo;
foo = function() {
  orig.call(obj);
}

foo();
foo.call(obj2);</script></body>
</html>
'use strict';
function foo() {
  console.log(this.bar);
}

var obj = {bar: 'bar'};
var obj2 = {bar: 'bar2'};

var orig = foo;
foo = function() {
  orig.call(obj);
}

foo();
foo.call(obj2);