css
css copied to clipboard
Update script.js
Changes:
- Used const and let instead of var for better scoping and avoiding potential issues with hoisting.
- Removed redundant false argument in event listeners, as it’s the default.
- Optimized the tocItems array creation using Array.from() instead of [].slice.call().
- Used template literals for easier string interpolation in the path creation.
- Simplified logic by using destructuring for targetBounds properties (top, bottom). This version should now be easier to maintain and perform slightly better.