coffeescript icon indicating copy to clipboard operation
coffeescript copied to clipboard

In Operator - IndexOf

Open thomasf1 opened this issue 10 months ago • 1 comments

The In Operator seems to have been broken for a while...

if 'github.com' in "https://github.com/jashkenas/coffeescript/issues/5481"
    alert 'Found'

Does not work (using the version on https://coffeescript.org/)

It renders to

var indexOf = [].indexOf;

if (indexOf.call("https://github.com/jashkenas/coffeescript/issues/5481", 'github.com') >= 0) {
  alert('found');:
}

Which doesn´t work:

indexOf.call("https://github.com/jashkenas/coffeescript/issues/5481", 'github.com')
-1
indexOf.call('github.com', "https://github.com/jashkenas/coffeescript/issues/5481")
-1

This works though

"https://github.com/jashkenas/coffeescript/issues/5481".indexOf('github.com')
37

That´s in chrome, not sure when indexOf.call is kinda broken

thomasf1 avatar Dec 18 '24 06:12 thomasf1