title: How to check if a function has been called? jQuery
body: <p>I've been given a script, which I cannot edit (as a part of an exercise). In the script, there is a function which generates random messages for a set of given [fake] users. (It's supposed to emulate a chat room).</p>
  
  <p>I need to detect when a message has been generated. As of now, the only thing I can think of is using <code>setInterval()</code> and repeatedly checking something like <code>length</code> to see if a new message has been added. However, I would like my chatroom to update <em>as</em> the messages are created so that it looks like it's done in real time (as opposed to only updating when it is noticed by <code>setInterval()</code>. I realize that I can have the interval be very small, but that seems highly inefficient, especially if there are larger gaps between messages.</p>
  
  <p>Is there some way to check if that function which generates messages has been "triggered"? </p>