Javascript -- when does it evaluate?

lunelson's picture

OK, so the answer to this question is probably in a FAQ somewhere; but I can't find it.

I remember reading something about how Javascript patches don't necessarily evaluate on every frame -- that they needed some kind of dynamic input (like Patch Time or something) to make them do so. Is this true?

Also: would the opposite case be true? -- that if you use a JS patch to generate a Structure for example, that it won't be regenerating on every frame, but rather only if you change any of its inputs?

Thanks for any tips, enlightenment

copy Nested Structures / Objects in Javascript

M.Oostrik's picture


I'm trying to copy a nested structure in the Javascript patch so i can manipulate it. The function i came up with does work, but it messes up the order of the structure.

function cloneObject(oldObject) {
   var newObject = new Object()
     for (i in oldObject) {
      if (typeof oldObject[i] == 'object') {
         newObject[i] = new cloneObject(oldObject[i]);
      else newObject[i] = oldObject[i];
    return newObject

Anyone has a suggestion? i'm kinda at the end of my javascript knowledge here. thanx