(Note: Roland Illig points out this algorithm is wrong, so I wrote this answer under the assumption it was correct.)
I think I understand what
LIM is, many people would argue you should probably just write it out as
LIMIT. However, these 3:
lb = 0,
ub = list.length - 1,
I have no idea what they mean. I would write out the names.
var LIM = Math.ceil(Math.log2(list.length))
It appears you are using
LIM to provide a termination point for your program. You really don't need this for a binary search. It is unnecessarily complicated. I think you should think more about what you should do instead of me just telling you what the alternative is. Get rid of
el !== list[i = ~~((lb + ub) / 2)] && el !== list[++i]
Is really hard to understand. Unless you have a good reason to write code like this I wouldn't do it. I haven't seen a binary search that has a line this cryptic. There should be a way of breaking this up into multiple lines.
Given you were confused about the output, splitting up into multiple line might be a good thing as it allows you to isolate where the issue is better.