In this Web 2.something era there's a big problem with noscript tag and I wonder what does W3 think about them. noscript and its standard implementation This tag is really useful to increase page informations or accessibility, allowing developers to show an alternative content if user has not JavaScript enabled or his browser doesn't support other kind of tags. <script type="text/jvascript">doStuff()</script> <noscript>Your browser can't do my Stuff</noscript> This is a basic example of noscript usage and expected behaviour is that every JS compatible browser will try to execute code insde script tag while every JS disabled or not compatible browser will show an alternative information. So, what's wrong with noscript ? When a browser is JS compatible ignores totally noscript tag. It doesn't render its informations, just " jump " after the end of this tag. At the same time, if a browser is not compatible with tag used bef...
There are way too many ways to stub functions or methods, but at the end of the day all we want to know is always the same: has that function been invoked ? has that function received the expected context ? which argument has been passed to that function ? what was the output of the function ? Update thanks to @bga_ hint about the output property in after notification, it made perfect sense The Concept For fun and no profit I have created a prototype which aim is to bring a DOM like interface to any sort of function or method in order to monitor its lifecycle: the "before" event, able to preventDefault() and avoid the original function call at all the "after" event, in order to understand if the function did those expected changes to the environment or to a generic input object, or simply to analyze the output of the previous call the "error" event, in case we want to be notified if something went wrong during function execution the "handlerer...
JavaScript constructors (call them classses if You prefere) have some problem with private parameters or private methods. To use a private parameter You should simply use a variable without this as scope prefix function MyConstructor(){ this.getPrivate = function(){ return private; }; var private = "something"; }; It's simple and it works perfectly. Any external scope could get directly private variable and You can know its value only calling getPrivate method. var obj = new MyConstructor; alert(obj.getPrivate()); The cool thing is that if You change externally returned value it will not be changed inside object too but please remember that if You change them and it's a generic object or an array, these changes will be valid inside object scope too (object and arrays are sent by reference, You need to clone or copy them before to return them externally). Well, this is just a private parameters introduction and this is not useful if You write only using prototype ...
Comments
Post a Comment