A object is passed to a function using java script - read write -

F

Frank H. Shaw

A object is passed to a function using java script - read write - issues. I
was reading in a book on javascript and it meatained the passing of a object
to a function is passed in with read and write capability but it did not go
into explaining it any more then that so could some one explain what that
means and why one needs such capability. Also it meantain that properitys did
not have read write in a function. One seems to contrdit the other please
explain.
 
K

Kevin Spencer

Hi Frank,

Sounds like the author was a bit unclear in his/her terminology, for
whatever reason. What he/she was describing was the concept of passing
variables by value or by reference. When a variable is passed by value, a
copy of the variable is passed to the function. Therefore, if you change the
value of the passed value, it has no effect on the actual variable that was
passed. When a variable is passed by reference, a pointer to the variable
itself is passed to the function. This means that when you change the value
of the passed variable in the function, you are changing the variable
itself.

So, what the author was saying (rather poorly) is that in JavaScript
variables are passed by reference. That is, for example, if you pass a
textbox to a function, and change the value of it in the function, the value
in the actual textbox is changed by doing so.

I sincerely appreciate your willingness to study and learn the principles of
programming!

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Ambiguity has a certain quality to it.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top