Javascript: Don’t Use ‘length’ and ‘width’ as Variables

I have been working on a Magento customization that calculates rug pricing by square foot. I’ve had to write a good amount of javascript to help with this, and I had everything working just fine in Firefox, Safari, and Chrome. But (surprise, surprise) IE was throwing errors. After some console logging and debugging, I finally figured out that if I changed my variable names in a function I had from ‘length’ and ‘width’ to ‘rugLengh’ and ‘rugWidth’, then IE stopped complaining and everything worked just fine.

I’m not much of a javascript programmer, though I can get by. This particular issue is still a mystery to me. If any of you know why this was happening, I’d love to know!

This entry was posted in Javascript. Bookmark the permalink.

5 Responses to Javascript: Don’t Use ‘length’ and ‘width’ as Variables

  1. keyur says:

    @nick yes we can….

  2. nick says:

    Can you make the Magento customized square foot pricing code available?

  3. mark says:

    These are reserved keywords in JavaScript

  4. Kamil says:

    Don’t ask why, it’s IE :)