Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #13389

Re: Javascript Tutorial - Leave a comment regarding this online tutorial

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!newsfeed.straub-nv.de!uucp.gnuu.de!newsfeed.arcor.de!newsspool3.arcor-online.net!news.arcor.de.POSTED!not-for-mail
Content-Type text/plain; charset="UTF-8"
Message-ID <1399409.AFRqVoOGUt@PointedEars.de> (permalink)
From Thomas 'PointedEars' Lahn <PointedEars@web.de>
Reply-To Thomas 'PointedEars' Lahn <cljs@PointedEars.de>
Organization PointedEars Software (PES)
Date Sun, 15 Apr 2012 10:19:24 +0200
User-Agent KNode/4.4.11
Content-Transfer-Encoding 8Bit
Subject Re: Javascript Tutorial - Leave a comment regarding this online tutorial
Newsgroups comp.lang.javascript
References <21708501.852.1334458849164.JavaMail.geo-discussion-forums@pbig5>
Followup-To comp.lang.javascript
MIME-Version 1.0
Lines 114
NNTP-Posting-Date 15 Apr 2012 10:19:25 CEST
NNTP-Posting-Host d9f3fc34.newsspool2.arcor-online.net
X-Trace DXC=L`Bk>8g7dnEFJ3]dH>I?oEA9EHlD;3YcB4Fo<]lROoRA8kF<OcfhCOK9oB1OC=45TLDZm8W4\YJNLJ`:FmdeL>K@U@3`]Ai;BfB>Z\KeJVW1RI
X-Complaints-To usenet-abuse@arcor.de
Xref csiph.com comp.lang.javascript:13389

Followups directed to: comp.lang.javascript

Show key headers only | View raw


Javascript replace wrote:

> Just posted a tutorial on the Javascript Replace method and need you to
> point out whether is there any error in that tutorial or not @
> http://gadgets-code.com/javascript-replace-method-review so I can further
> improve on that piece of tutorial and provide as accurate information as
> possible the the online Javascript lovers. Thanks. :)

0. You should have posted using your real name to avoid your posting being
   misinterpreted as spam.

0.1. You should not have posted using Google Groups, from which most spam
     messages to Usenet are injected nowadays.

0.2. You should have made yourself aware of the other shortcomings of
     Google Groups with regard to Network News, such as lack of proper
     automatic line-break.  Your posting consists of a single line of 335
     characters, which is inacceptable for plain-text Network News, 
     including Usenet (where you have posted to).

     Postings should be properly formatted and lines should not exceed 80
     characters per line.  One recommendation is to format the line so that
     it ends before the 76th character, to that there is room for quotation
     characters (`> > ').  See also <http://jibbering.com/faq/#posting> pp.

1. There is no "Javascript" (or "javascript").  You and your readers need to
   become aware that they are writing code that is executable in and
   (because of different host environments, necessarily) executed by
   several different implementations of ECMAScript that differ from one
   another:

   <http://PointedEars.de/es-matrix>

2. Improve your code style so that your readers learn how to write easily 
   readable (and thus inexpensively maintainable) code.  The comma should be
   followed by at least one space character.

3. Verbatim string literals may not be continued on the following line
   (some ECMAScript implementations, especially those conforming to Edition
   5, support continuing a string literal on the following line which has
   been delimited with a `\' character on the preceding line.  See section
   7.8.4.).

   This code of yours does not _compile_:

     var text = "You will replace him with new word, so go ahead and type 
any word into the input box now!";

   Modify your examples so that they compile and run as they are when copy
   pasted.  This can be accomplished best here with using string
   concatenation, slicing the one string value into two so that the line
   length does not exceed a reasonable common limit (such as 67 characters,
   which is the prevailing standard for fixed-width printouts):

     var text = "You will replace him with new word, so go ahead"
              + " and type any word into the input box now!";

4. Use window.alert(…) instead of alert(…), to make explicit that you intend
   to call a method of the object referred to by the `window' property
   of the global object, which does _not_ belong to any programming language
   (anymore; but to the AOM/DOM API instead).  The same applies to
   window.prompt(…).

5. Your definition of "word" is incorrect or your description of the replace
   example is imprecise.

     text.replace(/him/gi,repText)

   will _return_ the value of `text' with all _case-insensitive_
   _occurences_ (substrings) of "him" replaced by the value of `repText'.
   (The string value of `text' will remain _unchanged_.  String values
   are _immutable_ in ECMAScript implementations.)

   A word, on the other hand, is usually defined as a substring delimited by
   the start of input (or line), the end of input (or line), and/or non-word
   characters (such as white-space).  Whereas a word character is usually
   defined (and so by the `\w' and `\b' escape sequences in ECMAScript) to
   include the alphanumeric ASCII characters and the `_' (underscore)
   character (/\w/ ~ /[0-9A-Za-z_]/).  That is, the return value of

     "foobarbaz".replace(/bar/gi, "bla")

   is

     "fooblabaz"

   whereas "bar" surely cannot be considered a word in any sense, but a
   _substring_ instead.

6. Reconsider your use of the term "RegExp object".  There is only one
   `RegExp' object in (an) ECMAScript (implementation).  Objects created
   using the `RegExp' constructor/factory object (i. e., `new RegExp(…)' or
   `RegExp(…)') are thus called "RegExp _instances_' in the pertaining
   Editions of the ECMAScript Language Specification.  See for example
   Edition 5, section 15.10.7.
  
7. window.location.replace(…), i. e. the replace(…) method of the location
   object as referred to by the `location' property of window objects has
   nothing to do with all this.  Location objects are part of the
   AOM (Application Object Model) API provided by the host environment
   (a web browser, usually), not any programming language (anymore).

   If you think that method should be mentioned in that article at all, make
   it very clear that this method _has nothing to do_ with the method that
   you discussed previously, and why, so that you do not to mislead your
   readers.


PointedEars
-- 
Anyone who slaps a 'this page is best viewed with Browser X' label on
a Web page appears to be yearning for the bad old days, before the Web,
when you had very little chance of reading a document written on another
computer, another word processor, or another network. -- Tim Berners-Lee

Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Javascript Tutorial - Leave a comment regarding this online tutorial Javascript replace <arie3456@gmail.com> - 2012-04-14 20:00 -0700
  Re: Javascript Tutorial - Leave a comment regarding this online tutorial Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-04-15 10:19 +0200
    Re: Javascript Tutorial - Leave a comment regarding this online tutorial Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-04-15 10:36 +0200
      Re: Javascript Tutorial - Leave a comment regarding this online tutorial Javascript replace <arie3456@gmail.com> - 2012-04-15 02:11 -0700
    Re: Javascript Tutorial - Leave a comment regarding this online tutorial Javascript replace <arie3456@gmail.com> - 2012-04-15 02:27 -0700
      Re: Javascript Tutorial - Leave a comment regarding this online tutorial Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-04-15 11:44 +0200
    Re: Javascript Tutorial - Leave a comment regarding this online tutorial Dr J R Stockton <reply1216@merlyn.demon.co.uk.not.invalid> - 2012-04-16 20:10 +0100
  Re: Javascript Tutorial - Leave a comment regarding this online tutorial "Evertjan." <exjxw.hannivoort@interxnl.net> - 2012-04-15 15:39 +0000

csiph-web