When we touch a new language, we must first understand it and have some theoretical understanding of it.
So, what is JavaScript?
JavaScript is a scripting language that is interpreted and executed by a Web browser. It includes ECMAScript, Dom, and BOM.
Ecmascript:javascript Core Syntax (describes the syntax and basic objects of the JavaScript composition language)
Dom:brwoser Object Model Document objects (describes methods and interfaces for handling page content)
Bom:document Object Model Explorer (describes methods and interfaces for interacting with the browser)
What can it do?
JavaScript gives the page the soul, allowing the page to move, including dynamic data, dynamic tags, dynamic styles, and so on, to achieve the effect you want in a simpler way.
How do I apply JavaScript to a Web page?
Method One: Insert the JavaScript code into the <script> tab of the HTML Document
For example:
< Head > < type= "Text/javascript"> //JavaScript code alert ("Hello World"); </ Script > </ Head >
Method Two: Store the JavaScript code in a separate file (with. js as the file extension, and then use the SRC attribute of the <script> tag to point to the file)
For example: JS file named "Test.js"
// JavaScript code alert ("Hello World");
<!---<head> < Typesrc= "Test.js"></script> </ Head >
JavaScript syntaxOne, variable
First understand what is a variable, any programming language has a "variable", as the name implies, is the amount of variable content. It can be a very short amount used to store very long content, different content.
For example, a cup, can be installed 100ml of coke, can also be installed 200ml Coke, can also be installed 200ml of milk.
So why use variables?
The same code appears multiple times, called redundancy, not optimized, and poorly maintained.
1+1=2 in mathematics, equals equal to the left and right,
While programming age=20, the equals sign refers to the amount of the right value assigned to the left.
1. Variables are defined by the var operator plus the variable name.
For example: var name = "Mossbaoo";
var age = 20;
2. Naming rules for variable names:
① the first character must be a letter, underscore, or dollar sign;
② variable names cannot contain spaces or punctuation marks (except for underscores and dollar signs);
③ variable names are case-sensitive;
④ cannot use reserved words or keywords.
3. How to name a variable:
① Big Hump: UserName
② Small Hump: UserName
③ Hungary: User_name
4. Keywords, reserved words
Keywords: words that have a special meaning in JavaScript are called keywords
Reserved words: In the javscript there may be future as the key word is called the reserved word
key word Daquan
Break |
Do |
instanceof |
typeof |
Case |
Else |
New |
Var |
Catch |
Finally |
Return |
void |
Continue |
For |
Switch |
While |
Debugger |
function |
This |
With |
Default |
If |
Throw |
Delete |
Inch |
Try |
|
|
|
|
reserved word Daquan
Abstract |
Enum |
Int |
Short |
Boolean |
Export |
Interface |
Static |
Byte |
Extends |
Long |
Super |
Char |
Final |
Native |
Synchronized |
Class |
Float |
Package |
Throws |
Const |
Goto |
Private |
Transient |
Debugger |
Implements |
Protected |
Volatile |
Double |
Import |
Public |
|
|
|
|
5. Each JS statement to end with a semicolon, although it allows you to not add semicolons, but for the consistency of the program and rigor, the proposed addition to. Code as far as possible to write a neat point, the indentation is indented, the line is wrapped, good habits will start to develop.
JavaScript Basics Summary (i)