Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Page 1 of 2 12 LastLast
Results 1 to 15 of 20
  1. #1
    mbl
    mbl is offline
    New Coder
    Join Date
    Sep 2004
    Posts
    63
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Is JavaScript case-sensitive or not?

    Friends,

    Am new to Javascript but am an older-times programmer. Have read both that Javascript coding is case-sensitive and that it is not.

    Have started with n-vu web-page software and it flattens all code to lower case. So far that seems not to be a problem (me being it most of the time), but am used to using uppercase some letters on code to help on readability, and would like to be clear on the fundamentals, or what is the practice nowdays.

    Any help is welcome.

    Thanks.

    -mbl-

  • #2
    Banned
    Join Date
    Sep 2003
    Posts
    3,620
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Yes... Javascript is case sensitive... For readability most programmers use the camelCase convention...

    .....Willy

  • #3
    mbl
    mbl is offline
    New Coder
    Join Date
    Sep 2004
    Posts
    63
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thank you very much, Willie.

    However, how come the code stripped down all to lower case does not seem to matter to i.e. nor to FireFox? At least as little as I have done yet? Seems to me that the authors of n-vu (open-source web-page software) would know better not flatten down uppercases, yet n-vu does just that, and the code runs OK so far. What's going on?

    Is it that un-officially it does not matter to those browsers, or what?

    Thanks.

  • #4
    Regular Coder
    Join Date
    Aug 2004
    Location
    codegoboom@yahoo.com
    Posts
    999
    Thanks
    0
    Thanked 0 Times in 0 Posts
    somewhat related:

    Scripting Guidelines is a chapter which may be of interest to you.
    Although vbs-specific, I suspect the information is applicable to scripting in general.
    *this message will self destruct in n-seconds*

  • #5
    Master Coder
    Join Date
    Feb 2003
    Location
    UmeŚ, Sweden
    Posts
    5,575
    Thanks
    0
    Thanked 83 Times in 74 Posts
    The answer is as follows: There is not one iota of JavaScript on the nvu page. Not at all. It's all all HTML.

    In the light of this, I don't think you know what JavaScript really is, so...


    HTML was case insensitive. The most common form, almost an informal standard really, was to use all upper case for element and attribute names. This is also the form it is normalised to in the DOM.

    XML and XHTML are case sensitive. What case you use for your XML based language varies but in the case of XHTML all elements are lower case. Because of this future HTML version being all lower case and HTML being case insensitive, most web developers began using lower case only years ago. Web developers using XHTML are of course REQUIRED to use lower case.



    As for JavaScript, it is highly case sensitive. The only exceptions to this that I know are a few implementations of a the DOM0 events model.
    liorean <[lio@wg]>
    Articles: RegEx evolt wsabstract , Named Arguments
    Useful Threads: JavaScript Docs & Refs, FAQ - HTML & CSS Docs, FAQ - XML Doc & Refs
    Moz: JavaScript DOM Interfaces MSDN: JScript DHTML KDE: KJS KHTML Opera: Standards

  • #6
    Senior Coder
    Join Date
    Jun 2002
    Location
    Wichita
    Posts
    3,880
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by mbl
    Thank you very much, Willie.

    However, how come the code stripped down all to lower case does not seem to matter to i.e. nor to FireFox? At least as little as I have done yet? Seems to me that the authors of n-vu (open-source web-page software) would know better not flatten down uppercases, yet n-vu does just that, and the code runs OK so far. What's going on?

    Is it that un-officially it does not matter to those browsers, or what?

    Thanks.
    It sounds like you may be confusing Javascript which is and always has been case sensitive with the HTML code it's often embedded within which hasn't been case sensitive in the past but now (with xHTML) is.

    --- Edit ----

    I see Liorean posted the same basic information but in more detail.
    Last edited by Roy Sinclair; 09-08-2004 at 10:21 PM.
    Check out the Forum Search. It's the short path to getting great results from this forum.

  • #7
    Banned
    Join Date
    Sep 2003
    Posts
    3,620
    Thanks
    0
    Thanked 0 Times in 0 Posts
    how come the code stripped down all to lower case does not seem to matter to
    Actually the answer to that is quite simple...

    If everything was converted to lowercase... there is no mismatch.... MYFUNCTION OR MYVARIABLE will be converted to myfuntion or myvariable across the entire document...

    .....Willy

  • #8
    Regular Coder
    Join Date
    Jul 2002
    Location
    Kansas, USA
    Posts
    487
    Thanks
    0
    Thanked 54 Times in 53 Posts
    Of course there will be a problem if two different-cased, but otherwise identical, variable names are used: myVar and MyVar. When flattened they both become myvar and hilarity ensues.

  • #9
    Master Coder
    Join Date
    Feb 2003
    Location
    UmeŚ, Sweden
    Posts
    5,575
    Thanks
    0
    Thanked 83 Times in 74 Posts
    That's why any experienced coder never use the same name with just case variations. However, if you wish, there are worse things that may be done...
    <http://mindprod.com/unmain.html>
    liorean <[lio@wg]>
    Articles: RegEx evolt wsabstract , Named Arguments
    Useful Threads: JavaScript Docs & Refs, FAQ - HTML & CSS Docs, FAQ - XML Doc & Refs
    Moz: JavaScript DOM Interfaces MSDN: JScript DHTML KDE: KJS KHTML Opera: Standards

  • #10
    Banned
    Join Date
    Sep 2003
    Posts
    3,620
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Yes but that is not what I said...

    Although it would be possible to have two variables one named MyVar and another myVar it is my humble opinion that only an idiot would do that so that chances of that occuring would be in direct proportion to the number of idiots you are working with...

    .....Willy

  • #11
    mbl
    mbl is offline
    New Coder
    Join Date
    Sep 2004
    Posts
    63
    Thanks
    0
    Thanked 0 Times in 0 Posts
    "The answer is as follows: There is not one iota of JavaScript on the nvu page. Not at all. It's all all HTML.

    In the light of this, I don't think you know what JavaScript really is, so... " -Liorean-
    ......

    Dear Liorean,

    Will not disagree with you on being ignorant, but will say that THERE IS Javascript coding in the document that I have n-vu handle for me, and that's the code that I put in there myself.

    On that coding, which everyone calls Javascript, because some I copied from this forum, the OnMouseOve method or function, for instance, is flattened by n-vu to onmouseover. And so it is for the rest of the code.

    The little I've gathered is that Javascript IS NOT a self-sustained language, so it's called a script, and needs to run by a browser software as a document. So, to me, it'd look as if n-vu would have no rights to flatten JavaScript code, specially if Javascript is case sensitive, and if it isn't, then why bother to flatten it and do away with readability?

    However, the question relates also to, if JavaScript is case sensitive, how-come th I.E. and FireFox don't seem to care?

    Please help. Will check the links given by others a little later, and will try FrontPage next after installing it.

    Thank all for the answers, all are very valuable to me.

    -mbl-

  • #12
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,043
    Thanks
    0
    Thanked 251 Times in 247 Posts
    Quote Originally Posted by mbl
    On that coding, which everyone calls Javascript, because some I copied from this forum, the OnMouseOve method or function, for instance, is flattened by n-vu to onmouseover. And so it is for the rest of the code.
    onmousemove is an HTML attribute which happens to be an event handler. It is not Javascript, the value of that attribute is.

    The only Javascript in the sample below is the bold part.

    <img name="myImage" src="myimage.gif" onmousemove="myJavascriptFunction()" />

    The onmousemove attribute (or all attributes for that matter) is case-insensitive in HTML.

    Although event handlers are scriptable in Javascript.

    document.images['myImage'].onmousemove = myJavascriptFunction;

    in that case, onmousemove is case-sensitive.

  • #13
    mbl
    mbl is offline
    New Coder
    Join Date
    Sep 2004
    Posts
    63
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Dear Glenngv,

    Thank you very much for your very clear explanation.

    It will help me clear out on what is what. It looks like much HTML is called JavaScript but sometimes contains very little or maybe even none.

    Looks like JS has to be delinated as such or called by file from HTM. Did get quite confused by they sharing identifiers and capabilities.

    Appreciate it.

    -mbl-

  • #14
    Regular Coder
    Join Date
    Dec 2003
    Location
    America
    Posts
    544
    Thanks
    0
    Thanked 0 Times in 0 Posts
    LOL....dont yu just love charm, and sophistication in insults?
    LovesWar

  • #15
    Master Coder
    Join Date
    Feb 2003
    Location
    UmeŚ, Sweden
    Posts
    5,575
    Thanks
    0
    Thanked 83 Times in 74 Posts
    Quote Originally Posted by mbl
    Dear Liorean,

    Will not disagree with you on being ignorant, but will say that THERE IS Javascript coding in the document that I have n-vu handle for me, and that's the code that I put in there myself.
    Oh, then it was an misunderstanding from my part, I read that as the nvu site, not a site you're creating using nvu.
    On that coding, which everyone calls Javascript, because some I copied from this forum, the OnMouseOve method or function, for instance, is flattened by n-vu to onmouseover. And so it is for the rest of the code.
    Well the thing is (as described in posts above) that JavaScript and HTML are separate, one is case sensitive and the other is not. The JavaScript properties onmouseover etc. are all lower case, while the HTML properties are case insensitive.
    The little I've gathered is that Javascript IS NOT a self-sustained language, so it's called a script, and needs to run by a browser software as a document.
    Not quite, and by saying this you just reinforce my notion that you don't, or at least didn't at the time of posting, know what JavaScript really is. HTML is the language used for documents. Tags, attribute names, elements and all are just HTML. These are the case insensitive parts. Attribute values on the other hand are strings, and are case sensitive. JavaScript may be contained in or linked from [b]script[b] elements inside an HTML document, or may be contained in attribute values in HTML.
    So, to me, it'd look as if n-vu would have no rights to flatten JavaScript code, specially if Javascript is case sensitive, and if it isn't, then why bother to flatten it and do away with readability?
    I sincerely doubt nvu does anything at all with your JavaScript. Normally a good development environment for HTML documents has cleanup facilities to make the code better (or worse, depending on how good they are at cleaning). One of the frequently found features of these are element and attribute case consistency (it either turns all element and attribute names into upper case, or it turns all element and attribute names into lowercase), indentation, insertation of optional end tags for content containing tags, removal of redundant tags etc.
    However, the question relates also to, if JavaScript is case sensitive, how-come th I.E. and FireFox don't seem to care?
    They do. Try entering the following in the location bar javascript:AlErT('If JavaScript were case insensitive, this would work') and compare to what happens when you enter javascript:alert('...but JavaScript is case sensitive, thus this works but not the other one.')
    Please help. Will check the links given by others a little later, and will try FrontPage next after installing it.
    Please don't. FrontPage is not a good web development environment. (Though it's better today than it once were.)
    liorean <[lio@wg]>
    Articles: RegEx evolt wsabstract , Named Arguments
    Useful Threads: JavaScript Docs & Refs, FAQ - HTML & CSS Docs, FAQ - XML Doc & Refs
    Moz: JavaScript DOM Interfaces MSDN: JScript DHTML KDE: KJS KHTML Opera: Standards


  •  
    Page 1 of 2 12 LastLast

    LinkBacks (?)


    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •