question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

_handleArrowSelect function - uncaught reference (i) in for loop

See original GitHub issue

@stefanocudini

When I do any search and try to use the arrow key to navigate the results i receive a reference exception:

Uncaught ReferenceError: i is not defined

This is triggered by the for loop on line 828 in leaflet-search.src.js. i is an implicit global variable and in strict mode this will kick up an error:

for (i=0; i<searchTips.length; i++)

If you declare i then it fixes the error. It becomes a local variable i.e:

for (let i=0; i<searchTips.length; i++)

Can this be updated in the package?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
jt196commented, Aug 24, 2021

Dude, just updated to the 3.0.1 version and double checked the GitHub code, the line for (i=0; i<searchTips.length; i++) is still there, if you replace it with for (let i=0; i<searchTips.length; i++) as @Robc24 mentioned, the up/down arrow key function works again.

Read more comments on GitHub >

github_iconTop Results From Across the Web

javascript - How to fix "Uncaught ReferenceError" in a for..in loop
Normally, it would just iterate over the loop, but now it's throwing an error. Any help would be greatly appreciated! javascript · arrays ......
Read more >
For loop ReferenceError: 'i' is not defined in JS | bobbyhadz
The "ReferenceError i is not defined" error occurs when we forget to use the `let` statement to define the index variable in a...
Read more >
How to Resolve an Uncaught Reference Error in Javascript
The ReferenceError occurs when referencing a variable that does not exist or has not been initialized in the current scope.
Read more >
each() Uncaught ReferenceError: i is not defined - Treehouse
I'm getting a reference error. I'm retrieving json data via ajax. I'm able to post all the data to my console so I...
Read more >
ReferenceError: "x" is not defined - JavaScript - MDN Web Docs
Variables defined inside a function cannot be accessed from anywhere outside the function, because the variable is defined only in the scope of...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found