Created
November 16, 2019 19:03
-
-
Save trinadhkoya/a032c7ef6beb06a47c80c0ef6f1d99c5 to your computer and use it in GitHub Desktop.
JS Bin // source https://jsbin.com/nayifov
This file contains hidden or 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 chainingDemo = function() { | |
var i = 0; | |
var add = function(param) { | |
i=i+param; | |
return this; | |
} | |
var substract = function(param) { | |
i=i-param; | |
return this; | |
} | |
var print = function() { | |
console.log("value of i is "+i); | |
} | |
return { | |
add: add, | |
substract: substract, | |
print: print | |
} | |
} | |
var x = chainingDemo(); | |
console.log(x.add(3).substract(1).print()); | |
</script> | |
<script id="jsbin-source-javascript" type="text/javascript">var chainingDemo = function() { | |
var i = 0; | |
var add = function(param) { | |
i=i+param; | |
return this; | |
} | |
var substract = function(param) { | |
i=i-param; | |
return this; | |
} | |
var print = function() { | |
console.log("value of i is "+i); | |
} | |
return { | |
add: add, | |
substract: substract, | |
print: print | |
} | |
} | |
var x = chainingDemo(); | |
console.log(x.add(3).substract(1).print());</script></body> | |
</html> |
This file contains hidden or 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 chainingDemo = function() { | |
var i = 0; | |
var add = function(param) { | |
i=i+param; | |
return this; | |
} | |
var substract = function(param) { | |
i=i-param; | |
return this; | |
} | |
var print = function() { | |
console.log("value of i is "+i); | |
} | |
return { | |
add: add, | |
substract: substract, | |
print: print | |
} | |
} | |
var x = chainingDemo(); | |
console.log(x.add(3).substract(1).print()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment