After reading about prototype in JavaScript, I've created this JSFiddle to test some things about how functions work.
I understand that the prototype of the two functions are not the same. But why are the 'foo' and 'bar' functions the same as they have a different name and they both do different things?
The code:
var test1 = function(){
function foo(){
alert('test1 foo function');
}
}
var test2 = function(){
function bar(){
alert('test2 foo function');
}
}
if (test1.foo === test2.bar) {
alert("they're the same")
}
if (test1.prototype === test2.prototype){
alert("they're not the same")
}
test1.foo()?undefined.undefined.