View Single Post
Old 02-24-2013, 09:03 PM   PM User | #6
felgall
Master Coder

 
felgall's Avatar
 
Join Date: Sep 2005
Location: Sydney, Australia
Posts: 5,530
Thanks: 0
Thanked 503 Times in 494 Posts
felgall is a jewel in the roughfelgall is a jewel in the roughfelgall is a jewel in the rough
Quote:
Originally Posted by rnd me View Post
think of it like XHTML, there were transitional, frameset, and strict versions.
That's exactly what it is like.

In (X)HTML the strict doctype is there for people using only HTML 4 (or XHTML 1.0). The other two doctypes are for pages that are still transitioning from HTML 3.2 and which still use some of the long obsolete HTML 3.2 tags that were removed from HTML in 1997.

Similarly with JavaScript a number of unnecessary and problematic commands were removed from the language in 2011 but as a lot of scripts still use those now obsolete commands the "use strict" command was introduced to make it easier to test whether your code is using obsolete commands.


All new (X)HTML should be written using a strict doctype and all new JavaScript should be written so that it can work with "use strict". In both cases the other alternative is for old pages that are yet to be updated to follow the latest standard.

That most web pages still use HTML 3.2 even though HTML 4 has been the standard for over 15 years is because a lot of people do not understand that the transitional doctype is there for web pages that are transitioning from the long dead HTML 3.2 to the new HTML 4 standard.

With JavaScript the commands no longer recognised if you use "use strict" are those which the standards body have agreed should never have been a part of the language in the first place. Most would argue that they didn't go far enough but there then there is another round of changes to further fix the language that are intended to be released once more people stop using those commands that have now been removed (and which more experienced JavaScript programmers stopped using many years ago).

A web page using an HTML 4 transitional doctype might still be using HTML 3.2 and is supposed to be in the process of being rewritten to get rid of those tags deleted from HTML 4. A script that doesn't have "use strict" might or might not be using the poorly thought out JavaScript commands that were originally introduced in JavaScript and which were deleted in ECMAScript 5, but if you add "use script" and it still works in browsers that support that directive then you know that it complies with the latest standard and is not using obsolete code.


The current (X)HTML standard uses a strict doctype as pages written for HTML4/XHTML1.0 should not be written using HTML3.2 tags. The current JavaScript standard can use the "use strict" directive because pages written for EXCMAScript 5 should not be ECMAScript 3 commands that are no longer a part of JavaScript but which are now supported simply to avoid breaking all the antiquated scripts that still use them. The reason callee is included in ECMAScript 5 & 6 is as a deprecated command for backwards support for older scripts that still use it. Having seen that most of the web is still written using HTML 3.2 tags those looking after the JavaScript standards don't expect all of the now obsolete JavaScript commands to disappear all that quickly either - especially when some people appear to be assuming that the new version of JavaScript is a subset when in fact it still contains unnecessary commands that are still valid but which shouldn't be used.


Anyway, you still haven't responded to the question I asked in my first post on this thread. I agree that what you are trying to do here is a good idea. Do you have any thoughts on how to implement it without using commands that were removed from JavaScript back in 2011?
__________________
Stephen
Learn Modern JavaScript - http://javascriptexample.net/
Helping others to solve their computer problem at http://www.felgall.com/

Last edited by felgall; 02-24-2013 at 09:13 PM..
felgall is offline   Reply With Quote