We should use ``haystack.lastIndexOf(needle || '', 0)`` to avoid checking the entire haystack.