Is JavaScript case sensitive?

 Posted by vishalneeraj-24503 on 12/6/2013 | Category: JavaScript Interview questions | Views: 1625 | Points: 40

Yes,it's purely case-sensitive.

For ex:-

we can write getElementById function not getElementbyID.
we can write function not Function.
we can write ClientID not clientId or Clientid.

We can understand all cases by simple example:-

function do_stuff()

var txt_name = document.getElementById ('<%=txt_name.ClientID %>');


Function ->Will give run-time error as
"Expected ';' and JavaScript runtime error: 'do_stuff' is undefined"

getElementByID -> It will show run-time error as
"Object doesn't support property or method 'getElementByID'"

ClientID -> If we provide ClientId or clientId then it will give compile-time error as

"System.Web.UI.WebControls.TextBox' does not contain a definition for 'ClientId' and no extension method 'ClientId' accepting a first argument of type 'System.Web.UI.WebControls.TextBox' could be found (are you missing a using directive or an assembly reference?)"

Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response