Created
February 21, 2020 02:48
-
-
Save mixj93/9719965db738c64446cd67602bda0a47 to your computer and use it in GitHub Desktop.
JS Bin // source https://jsbin.com/kaxijeq
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width"> | |
<title>JS Bin</title> | |
</head> | |
<body> | |
<script id="jsbin-javascript"> | |
var myObj = { | |
value: 0 | |
} | |
myObj.increase = function(step) { | |
this.value += typeof step === 'number' ? step : 1 | |
} | |
myObj.double = function() { | |
this.value = this.value * 2 | |
} | |
myObj.double2 = function() { | |
var that = this | |
var helper = function() { | |
console.log(this) | |
console.log(that) | |
} | |
helper() | |
} | |
myObj.increase() | |
console.log(myObj.value) | |
myObj.double() | |
console.log(myObj.value) | |
myObj.double2() | |
</script> | |
<script id="jsbin-source-javascript" type="text/javascript">var myObj = { | |
value: 0 | |
} | |
myObj.increase = function(step) { | |
this.value += typeof step === 'number' ? step : 1 | |
} | |
myObj.double = function() { | |
this.value = this.value * 2 | |
} | |
myObj.double2 = function() { | |
var that = this | |
var helper = function() { | |
console.log(this) | |
console.log(that) | |
} | |
helper() | |
} | |
myObj.increase() | |
console.log(myObj.value) | |
myObj.double() | |
console.log(myObj.value) | |
myObj.double2()</script></body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var myObj = { | |
value: 0 | |
} | |
myObj.increase = function(step) { | |
this.value += typeof step === 'number' ? step : 1 | |
} | |
myObj.double = function() { | |
this.value = this.value * 2 | |
} | |
myObj.double2 = function() { | |
var that = this | |
var helper = function() { | |
console.log(this) | |
console.log(that) | |
} | |
helper() | |
} | |
myObj.increase() | |
console.log(myObj.value) | |
myObj.double() | |
console.log(myObj.value) | |
myObj.double2() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment