What are JScript's case sensitivity rules?

I am using ScriptControlClass for reference and I thought JScript is case sensitive ... However my user base surprised me ... I have several methods that I have provided to users in all the top ones like: IF, EMPTY, AGE, PARSE etc.

Okay, today a user filed a defect that issampgroup was not working. I researched and informed the user that the ISSAMPGROUP function and that it works correctly ... The user replied, all other functions except IF worked in lowercase. So I ran a quick test and all but 5 of my functions work in a case insensitive manner. I was very surprised to see the age and age, as well as all the other options for working and working properly. Below is an example of how my functions are declared and I have verified that the Jscript function calls my C # every time ...

this.scriptEngine.AddCode (@ "function AGE (birthDate) {return cmd.Age (birthDate);};");
this.scriptEngine.AddCode (@ "function ISSAMPGROUP (value) {return cmd.IsSampleGroup (value);};");

Which leaves me confused as to why some functions work in a case-insensitive way and others don't. For example, AGE is case insensitive, but ISSAMPGROUP is case sensitive.

+2


source to share


2 answers


The answer to this question is pretty simple: JavaScript is case sensitive, but browser vendors may choose to implement their JavaScript engine in a way that makes it more forgiving where possible.

So you should treat JavaScript as very case sensitive and anything that works with the wrong case should still be fixed as the engines from vendor to vendor script may differ and may not work in all browsers, only the most forgiving browsers ...

You also pointed out how ALL CAPS are not very good at denoting things, especially with acronyms.

function IsSampleGroup

      



Easier to read than

function ISSAMPGROUP

      

The reason why some might work and others might not be limited to naming conflicts i.e. is there any other similar object in JavaScript. MyVariable and myVariable and MYVARIABLE.

0


source


JavaScript IS is case sensitive. As mentioned, some browsers don't always take this into account, but as a general rule, you should always code for case sensitivity and scope to prevent problems.



0


source







All Articles