Created
June 10, 2015 23:18
-
-
Save ericpkatz/2177e68414d691a3ec88 to your computer and use it in GitHub Desktop.
JS Bin // source http://jsbin.com/wedexo
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"> | |
<title>JS Bin</title> | |
</head> | |
<body> | |
<script id="jsbin-javascript"> | |
console.clear(); | |
function Foo(b){ | |
this.counter = 0; | |
this.bar = b; | |
this.sayHi = function(){ | |
console.log(this.bar); | |
}; | |
this.SAYHI = function(){ | |
var msg = this.bar + "!!!!!!"; | |
console.log(msg); | |
this.counter = this.counter + 1; | |
}; | |
} | |
var f1 = new Foo(42); | |
f1.SAYHI(); | |
var f2 = new Foo(18); | |
var f3 = new Foo(7); | |
var arr = [ f2, f1, f3]; | |
for(var i = 0; i < arr.length; i++){ | |
arr[i].SAYHI(); | |
} | |
console.log(f1.counter); | |
console.log(f2.counter); | |
</script> | |
<script id="jsbin-source-javascript" type="text/javascript">console.clear(); | |
function Foo(b){ | |
this.counter = 0; | |
this.bar = b; | |
this.sayHi = function(){ | |
console.log(this.bar); | |
}; | |
this.SAYHI = function(){ | |
var msg = this.bar + "!!!!!!"; | |
console.log(msg); | |
this.counter = this.counter + 1; | |
}; | |
} | |
var f1 = new Foo(42); | |
f1.SAYHI(); | |
var f2 = new Foo(18); | |
var f3 = new Foo(7); | |
var arr = [ f2, f1, f3]; | |
for(var i = 0; i < arr.length; i++){ | |
arr[i].SAYHI(); | |
} | |
console.log(f1.counter); | |
console.log(f2.counter); | |
</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
console.clear(); | |
function Foo(b){ | |
this.counter = 0; | |
this.bar = b; | |
this.sayHi = function(){ | |
console.log(this.bar); | |
}; | |
this.SAYHI = function(){ | |
var msg = this.bar + "!!!!!!"; | |
console.log(msg); | |
this.counter = this.counter + 1; | |
}; | |
} | |
var f1 = new Foo(42); | |
f1.SAYHI(); | |
var f2 = new Foo(18); | |
var f3 = new Foo(7); | |
var arr = [ f2, f1, f3]; | |
for(var i = 0; i < arr.length; i++){ | |
arr[i].SAYHI(); | |
} | |
console.log(f1.counter); | |
console.log(f2.counter); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment