Home  >  Article  >  Web Front-end  >  Some Tips for JavaScript Study Notes_Basic Knowledge

Some Tips for JavaScript Study Notes_Basic Knowledge

WBOY
WBOYOriginal
2016-05-16 18:31:13953browse

1. JavaScript basics

1.try...catch uses lowercase letters. Capital letters will go wrong. ​

2.Throw statement

The purpose of the throw statement is to create an exception. You can use this statement with a try...catch statement to control program flow and produce precise error messages.

Syntax:
throw(exception)
exception can be a string, integer, logical value or object.

Note: Use lowercase letters to write throw. Using capital letters would be an error!

3. Backslashes are used to insert ellipses, newlines, quotation marks and other special characters in text strings. ​


The following table lists the remaining special characters that can be added to text strings using backslashes:

Code output
' single quote
" double quote
& ampersand
\ backslash
n newline character
r carriage return
t tab character
b Backspace character
f Form feed character
4. JavaScript will ignore extra spaces, so you can add appropriate spaces in the code to make the code more readable.

5.

You can use backslashes inside text strings to wrap code. The following example is correct:

document.write("Hello

World!")
But you can’t break lines like this:

document.write

("Hello World!")

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn