0

I have an array of objects in Javascript. Can I change the object values like this.

  • query ~ the array
  • propertyIndex ~ a value that is the index of the array element
  • selected ~ one of the variables of the object that is saved to the array
  • true ~ the value I want to set selected to be equal to

Code:

 query[propertyIndex].selected='true';
2
  • No reason, expect I thought that was causing a bug, I'l' change it back in my code. Commented Apr 11, 2011 at 6:51
  • 2
    Just a quibble - "selected" isnt' a variable, it's a property. :-) Commented Apr 11, 2011 at 6:58

1 Answer 1

2

Yes, you can do that.

What went wrong when you tried it?

Sign up to request clarification or add additional context in comments.

1 Comment

Well my code wasn't working, and I was wondering if this was legal or not. I assumed it must be but couldn't find the answer on Google.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.