In one of the tests, I need to scroll into view of an element which can be done via
var elm = element(by.id("myid"));
The first one is exposed to an unexpected/stale state. The element found by
element(by.id("myid")) could be removed from the page just before executing
browser.executeScript(). The second one is not exposed to this issue since the page is not updated while the script is executed.
The second one is less expensive since it executes one Selenium command (ExecuteScript), while the first one executes two (FindElement and ExecuteScript). Sending a Selenium command to the browser is relatively expensive (minimum of 25ms) and might become significant with multiple calls.
Both will produce the exact same result and will end up calling the same API on the browser side.