I stunbled on this through stackoverflow and it is a great resource and there is alot of conversation on this but i'm just still baffled why certain things dont work?
I studied c++ in college and sorta remember pointers
http://www.permadi.com/tutorial/jsFunc/index2.html
my problems are started in the code certain things aren't working
function theAdd(a, b){
return a*b;
}
//creating a copy of the function
var add3 = new theAdd();
add3.name = 'nameProperty';
//alert( add3(1,2)) //why doesn't this work?
alert(theAdd(5,5) + " " + theAdd.name);
function Ball() {
return 'balltext';
}
var ball0=new Ball(); // ball0 now points to a new object
alert( Ball() ); // this works
alert( ball0() ); // why doesn't this work? shouldn't it return balltext?
ball0is object, not afunction. You cann't use operator()on itnewoperator actually does.newdoes not do what you think it does. It actually creates an instance of an object.theAddperforms multiplication ;)add3.namesets the name foradd3only. Just that instance. It doesn't modifytheAddat all.