can you use parameters some how to alter 'book' and 'person' in this statement : book.borrower= person; eg JSObj.borrower = "SteveJobs"; I cannot seem to find a way, Is there one?
+1
A:
Maybe you meant to have something like this:
function changeBorrower(book, person)
{
book.borrower = person;
}
// USAGE
changeBorrower(JSObj, "SteveJobs");
Makram Saleh
2009-09-10 10:02:43
Makram, thanks for your responseIn fact I have similar code iefunction loanbook (book, lender) {book.borrower = lender;alert(book.borrower);}loanbook("JSObj", "Frank");but its not working??
2009-09-10 10:22:39
Further to your response, I noticed you had no "" around JSObjI have removed mine and it works fine, why is that?Thank you so muchAlan
2009-09-10 10:31:31
Because a string literal and a variable are completely different things.
David Dorward
2009-09-10 15:47:57
David,thanks...what a bunny...i've just started playing with OOP. I understand now, thank you for your response
2009-09-10 22:18:13