Speaking from the view of a home inspector, some of the answers are not technically correct.
First, few homes are actually constructed to the current code - they are constructed to meet the variation of the code adopeted by the local jurisdiction at the time of construction. Some jurisdictions are 5-7 years behind in updatig their codes. Others have poor (or overworked) code inspectors who miss items. Even a home built 3 years ago wouldn't necessarily pass todays code. I am not a realtor, but I have been told that things like updated wiring and plumbing do not equate to increased sale value (whereas updated kitchens and baths may increase the sale value).
Next, while some materials and methods used in current construction are advertised as "better" or "stronger" they have not been in use long enough to identify their weaknesses and failngs. PB (grey plastic) pipe was thought to be a great advancement in the 70s and early 80s, until it became the subject of a lot of failures and a huge class action suit. Asbestos was thought to be great stuff when it came out, too...... Myself, when I construct something, I prefer a solid piece of wood to the finger jointed lumber that many builders use, for example.
Still, there are a good number of features and materials that are improvements (like improved roof venting standards, manufactured trusses, and fire safety codes for example) but those rarely sell a home. So, structurally and mechanically, there is little to support a price difference between homes of different ages in the same location. This would seem to indicate that it is more reliant on cosmetic concerns, features, and design.
We tend to like "new" things as opposed to "used" things. Bigger, better, shinier. We may never use that 3rd bath, but it's great to have!! I also think there is something to the idea of functional obsolescence, especially wqith regard to layout, that was mentioned previously.
Hope this helps!