Every object has its properties and methods ( Here called 'members' ).
This lesson lets you inspect those of document, window, navigator and a button, whose names start with one letter entered ( for performance's sake ).
Keep in mind that the only object members that modern browsers have in common, are those coarsely summarized by :
ECMAScript 3, DOM Level 1 and CSS 1. These standards are implemented for 99%. Apart from standards, browsers have many proprietary additions, but using those depends on the audience you will be targeting. Keep in mind that there are lots of Firefox users these days, MSIE doesn't have the upper hand any more.
This button pressed will pass a reference to the 'document' object ...
to this function,...
where all members are shown using this special 'for' variant.
Show each member's name and contents,...
but only those with a name starting with the letter entered.
Make a string ...
to be able to use charAt.
It's easy to add members, to extend an object.
Two methods are added to 'String', one of the 'Global Objects' , 'startsWithVowel' and 'devowelize'.
In the first method, if the first character of the string concerned, 'this.toString()' ....
is equal to one of these vowels, the method returns true. '||' stands for 'OR'.
It is called here, to determine which colour to set the text box to.
And again, to show the boolean in the text area.
The string to which the method applies, is the one created with the expression 'new String', where the text box's value is passed as argument.
The text box's value, a string, can have its vowels removed ...
by this method.
The first argument is a regular expression, that says 'any of the occurrences of the letters enumerated, including uppercase ' are to be replaced by an empty string. The 'g' means 'global', making it apply to all occurrences and the 'i' is short for 'ignore case'.
A text box's value is already a string, so there's actually no need for 'new String', then.
This goes to show, that methods (or properties) added to String in the manner shown can then be used from that moment on any string.