|
INTERVIEW QUESTIONS
WEB
JAVA SCRIPT
DETAILS
Question: How do I ... with JavaScript/JScript ... use quotation marks when scripting?
Answer: There are two types of quote mark in JavaScript, the single-quote (') and double-quote ("). Either can be used to delimit a string literal, or sequence of characters. For example:
myDblQString = "This string is surrounded by double-quote marks."; mySngQString = 'This string is surrounded by single-quote marks.';
However, since HTML itself makes extensive use of double-quotes within tags, it's a good idea to use single-quotes to set off strings in your scripts. This is particularly useful when your code contains quoted elements, as follows:
onClick = "alert( 'Are you sure?' )";
Strings containing apostrophes, which are identical to single-quotes, require you to use the backslash character () to escape the apostrophes, as shown below:
myEscString = 'John didn't like Mary's hat.';
Quoted strings can be combined with other strings, whether literals or variables:
errMsg = "Passwords are case-sensitive."; message = "Error: " + errMsg; // assigns 'Error: Passwords are case-sensitive.' to message
|
|
|
Category |
Java Script Interview Questions & Answers -
Exam Mode /
Learning Mode
|
Rating |
(0.2) By 7994 users |
Added on |
10/6/2012 4:52:53 AM |
Views |
67748 |
Rate it! |
|
|
Question:
How do I ... with JavaScript/JScript ... use quotation marks when scripting?
Answer:
There are two types of quote mark in JavaScript, the single-quote (') and double-quote ("). Either can be used to delimit a string literal, or sequence of characters. For example:
myDblQString = "This string is surrounded by double-quote marks."; mySngQString = 'This string is surrounded by single-quote marks.';
However, since HTML itself makes extensive use of double-quotes within tags, it's a good idea to use single-quotes to set off strings in your scripts. This is particularly useful when your code contains quoted elements, as follows:
onClick = "alert( 'Are you sure?' )";
Strings containing apostrophes, which are identical to single-quotes, require you to use the backslash character () to escape the apostrophes, as shown below:
myEscString = 'John didn't like Mary's hat.';
Quoted strings can be combined with other strings, whether literals or variables:
errMsg = "Passwords are case-sensitive."; message = "Error: " + errMsg; // assigns 'Error: Passwords are case-sensitive.' to message Source: CoolInterview.com
If you have the better answer, then send it to us. We will display your answer after the approval.
Rules to Post Answers in CoolInterview.com:-
- There should not be any Spelling Mistakes.
- There should not be any Gramatical Errors.
- Answers must not contain any bad words.
- Answers should not be the repeat of same answer, already approved.
- Answer should be complete in itself.
|
|
Related Questions |
View Answer |
|
How do I ... with JavaScript/JScript ... use the same variable name several times in a script?
|
View Answer
|
|
How do I ... with JavaScript/JScript ... embed JavaScript in a web page?
|
View Answer
|
|
How is JavaScript syntax like C / C++?
|
View Answer
|
|
How does JavaScript model the world?
|
View Answer
|
|
What are the language's basic entities?
|
View Answer
|
|
Where is the official bug list for JavaScript?
|
View Answer
|
|
Where can I find online documentation for JavaScript?
|
View Answer
|
|
What is JavaScript?
|
View Answer
|
|
How i will use email validation in java script, Like. User can't enter invalid email address?
|
View Answer
|
|
What is the main difference between Client side Java Script and and Server side Java Script how actully they run on both side with Example
|
View Answer
|
|
I do not want to go next field without filling the text? Whic function i should use. Phone No Text validation in javascript
|
View Answer
|
Please Note: We keep on updating better answers to this site. In case you are looking for Jobs, Pls Click Here Vyoms.com - Best Freshers & Experienced Jobs Website.
View All Java Script Interview Questions & Answers - Exam Mode /
Learning Mode
|