1. Preface
- ECMAScript explanation, used to explain JS code
- DOM Document Object model, the browser needs to render the DOM tree when it is displayed
- BOM Browser object model, you can control the browser behavior, code compatibility is poor
2. Basic type
Number type: var a = 12;
String: var a = "string";
function Type: var a = function ()
Object type: var a = document
Boolean type: var a = Boolean
The type of a variable is determined by its assignment.
3. Type conversion
<!DOCTYPE HTML><HTML><Head> <title>Sum</title> <Scripttype= "Text/javascript">window.onload= function (){ varobtn=document.getElementById ('btn'); Obtn.onclick= function (){ varOINPUT1=document.getElementById ('INPUT1'); varOInput2=document.getElementById ('Input2'); varvalue1=parseint (oinput1.value);//Convert a string to an int varvalue2=parseint (Oinput2.value); if(!IsNaN (value1)&& !IsNaN (value2))//determine if a variable is a numeric typeAlert (value2+value1); } } </Script></Head><Body> <inputtype= "text"ID= "INPUT1"> <inputtype= "text"ID= "Input2"> <ButtonID= "BTN"type= "button">Sum</Button></Body></HTML>
- Implicit type conversions
= = value Equal is True
= = = Type is equal and the value equals True
+ String Connector/number addition
-Converts a string to a numeric subtraction operation
4. Scope of variables
5.json parsing
<!DOCTYPE HTML><HTML><Head> <title>Json</title> <Scripttype= "Text/javascript"> varJSON={A: A, B:"SSS", C:12.4}; alert (JSON.A); Alert (json['b']); </Script></Head><Body></Body></HTML>
<!DOCTYPE HTML><HTML><Head> <title>Json</title> <Scripttype= "Text/javascript"> varJSON={A: A, B:"SSS", C:12.4}; //TMP is the key, Json[tmp] is the value for(vartmpinchJSON) alert (json[tmp]); </Script></Head><Body></Body></HTML>
JavaScript Basics (1)