Question

Naming an input field 'Date' screws up javascript intellisense in my Visual Studio 2012. Makes me wonder if this is considered bad practice?

<script>
    var d = new Date();
    d. <-- no intellisense
</script>
<input type="text" name="Date" />
Was it helpful?

Solution

Normally it's better not to use languages reserved words, there are sometimes ways to scape them, but it could confuse yourself in the future if you need to modify something anyway, or even worse, if somebody else needs to modify your work.

You can always use intuitive prefixes for example:

myDate
inputDate
formDate
etc
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top