|
JavaScript Home
JavaScript TutorialIntroductionHow to Enable JavaScript JavaScript Syntax JavaScript Popup Boxes JavaScript and HTML External JavaScript File JavaScript Operators JavaScript Variables JavaScript Functions JavaScript Events JavaScript If Statements JavaScript Switch Statements JavaScript While Loop JavaScript For Loop JavaScript Try Catch JavaScript Escape Characters JavaScript Void(0) JavaScript Cookies JavaScript Date and Time JavaScript Arrays Two Dimensional Arrays JavaScript innerHTML JavaScript Summary JavaScript ReferenceJavaScript Reserved WordsJavaScript Event Handlers JavaScript Date and Time Functions JavaScript ExamplesList of ExamplesJavaScript Dropdown Menu JavaScript Print JavaScript Alert Box JavaScript Confirm JavaScript Prompt JavaScript Status Bar Messages Image Rollovers Popup Windows JavaScript Redirect Timed JavaScript Redirect JavaScript Refresh Page FREE Hosting!With every domain name you register with ZappyHost, you get FREE hosting.$1.99 Domain NamesWith every new non-domain purchase thru ZappyHost, you get a domain name for only $1.99. |
JavaScript Escape CharactersWhen working with strings, you'll notice there are some characters that always seem to break your program. These include apostrophes, ampersands, double quotes etc. When working with these characters, you need to use what is known as an "escape character". An escape character enables you to output characters you wouldn't normally be able to, usually because the browser will interpret it differently to what you intended. In JavaScript, the backslash (\) is an escape character. As an example, let's say I want to display the following text: They call it an "escape" character. Let's try that without an escape character: Without an escape character:
The above code won't work as intended because, as soon as the browser encounters the first double quote, it will think that the string has finished. Further, it will result in an error because it will be expecting the closing bracket. Code with an escape character:
The resulting output: The above code will display the double quotes as intended. Enjoy this website?
Oh, and thank you for supporting Quackit! |
Need Content for your Website?Get unique, quality digital content for your website. You can even earn money by reselling it!Includes:
|