playing with javascript function - object with naming and cloning
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?
No comments:
Post a Comment