Differences when using functions for casper.evaluate <p>I'm using PhantomJS v2.0 and CasperJS 1.1.0-beta3. I want to query a specific part inside the page DOM.</p> <p>Here the code that did not work:</p> <pre><code>function myfunc() { return document.querySelector('span[style="color:#50aa50;"]').innerText; } var del=this.evaluate(myfunc()); this.echo("value: " + del); </code></pre> <p>And here the code that did work:</p> <pre><code>var del=this.evaluate(function() { return document.querySelector('span[style="color:#50aa50;"]').innerText; }); this.echo("value: " + del); </code></pre> <p>It seems to be the same, but it works different, I don't understand.</p> <p>And here a code that did also work:</p> <pre><code>function myfunc() { return document.querySelector('span[style="color:#50aa50;"]').innerText; } var del=this.evaluate(myfunc); this.echo("value: " + del); </code></pre> <p>The difference here, I call the myfunc without the '()'.</p> <p>Can anyone explain the reason? </p>