Basics first day of learning javaScript

Basics first day of learning javaScript
1.1 Use:
Data Validation
read and write HTML elements of
interactivity with the browser window and its contents
netnew
WEB game production
server-side programming technology based Node.js

2.1 js the writing position
1 within the writing body tag, one pair of internal script tag. (Js code written on the tags of all the final structure)
. 1 <body>
2 <div class = "Box"> cartridge </ div>
. 3 <-! Js accustomed to writing at the end of all tags ->
4 <! - --1 js writing the tag within the one pair of body script tag ->
. 5 <script type = "text / JavaScript">
. 6 Alert ( "pop-up");
. 7 </ script>
. 8 </ body>

2 head tab, one pair of internal script tag
is introduced by the src js file, js files are plain text files, using any text editor can. .Js extension
will js written statements directly in the js file without writing the script tag
1 <script type = "text / javascript" src = "js / 01.js"> </ script>

js itself does not own the browser loaded, must rely html carrier to achieve in your browser.

Alert 2.2 ()
Alert (): represents the pop-up box, alert box.
alert (): indicates a process function. alert must be followed to add a small number of broad representation execution. Writing content to be displayed in a pair of double quotes. Add a semicolon at the end indicates the end of the statement.
Object: a collection of properties. A thing, such as human
attributes: An object features, characteristics. For example, a person's height, people of color
Method: An object with a behavior, such as people eat

alert call the object is window, but generally omitted writing.
The object method ()
. Object Properties
1 // js all written statements
2alert ( "I was inside the text");
3 // Alert the calling object is window, do not write omitted
4window.alert ( "I'm a window object method");

js Note
1 js statements are no special instructions are executed in the order from top to bottom.

2 js statement to a space, indentation, line breaks insensitive
1alert ( "I was inside the text"); window.alert ( "I'm a window object's method"); alert ( "I am the third sentence");
2
3
4
5alert ( "last statement");

The end of the 3 js statements must add a semicolon to indicate the end of the statement.
1 // js each statement must be added to the end of the semicolon indicates the end of the statement
2alert ( "first");
3alert ( "second");
4alert ( "third");

Do not write a semicolon, js statement has been read until the next statement is a semicolon or a newline know that this is the end of the statement.
1 // these statements will normally perform
2alert ( "first")
3alert ( "second")
4alert ( "third")

Before the code will be submitted to all spaces, indentation, line breaks removed, it is an error.
1alert ( "first") Alert ( "second") Alert ( "third")

2.3 Notes
js comment.
1 single-line comment, the comment only single line of text, line can not continue to comment
Ctrl + /
1 // a single line comment

2 Multi-line comment, the comment may be multi-line text
Ctrl + Shift + /
. 1 / multi-line comment /

2.4 console panel
console panel, you can use the F12 quickly open. Or right-examination.

console panel functions:
1 can be summarized js error message.

2 console js built-in objects, there are a lot of built-in method. A method wherein log (log)
the console.log (), the output of the internal width of the small number written in the pair of double quotes.
It said it will output the contents of the console panel.

Front-end Internet exchange study group: 937 268 047
Share happy, also witnessed the personal growth process, most of the articles are summarized as well as the usual learning experience accumulation, lack of self-awareness is inevitable based at, and please correct me, and common progress.

Guess you like

Origin blog.51cto.com/14334627/2404983
Recommended