Fundamentals of JavaScript -- Super detail (concept variable)

cjh_ code 2021-11-25 15:23:05

Catalog

1.1 JavaScript brief introduction

1.1.1  What is? JavaScript?

1.1.2 Why should we learn JavaScript?

1.1.3 Browser execution JavaScript Code process

1.1.4 JavaScript Component part

1.1.5 JavaScript Where to write

1.2 Variable

1.2.1 Naming conventions and rules

1.2.2 Exchange variables

1.2.3 data type


1.1 JavaScript brief introduction

1.1.1  What is? JavaScript?

JavaScript It's a door web Page Scripting language . abbreviation :JS;

1.1.2 Why should we learn JavaScript?

web Page construction can be divided into :

  1. structure :HTML The definition is the content of the web page, that is, the structure
  2. performance : Describe the layout of the web page , Add the style 、 Beautify the web page and so on
  3. Behavior : Control the interaction of web pages 、 Dynamic effects are behavior

1.1.3 Browser execution JavaScript Code process

1.1.3.1 Browser two engines :

  1. analysis HTML、css The rendering engine ( kernel ), such as Chrome Of webkit At the heart of .
  2. Parsing performed JavaScript Of JS engine

Expand ( Common browser private prefix ):

  1.    -moz-: On behalf of Fox
  2.    -ms-: representative ie
  3.    -webkit-: representative safari,chrome
  4.    -o-: representative Opera

1.1.3.2  Execution process :

        js The engine will read it JavaScript Code for , Then sentence by sentence will js Code to machine language code .

1.1.4 JavaScript Component part

  1. ECMA Script:js Basic content , Namely js Basic grammatical norms of language ( This article is based on ES5 standard , expand ES6 standard )
  2. DOM: utilize js A series of contents of code operation elements
  3. BOM: utilize js Operate some contents of the browser

1.1.5 JavaScript Where to write

  1. Inline : Write... In the inline label js Code ( Generally not recommended )
  2. The embedded : On the page <script></script> writes js Code
  3. Outer chain : newly build js file , stay js Write the code in the document , utilize <script src=" File address "></script> To import files  

  Three basic pop ups :

  1. alert(' Alert box '):
  2. prompt(' Input box '):
  3. confirm(’ OK cancel box ‘):

console Modal tool :

  1. console.log(): It is used to print information from the console
  2. console.dir(): Used to output the properties and methods of an object
  3. console.error(): Used to output error messages to the console

1.2 Variable

1.2.1 Naming conventions and rules

The rules :

  • By letter 、 Numbers 、 Underline 、$ The symbols make up , Cannot start with a number, such as :usrAge, num01, _name
  • Can't be keywords and reserved words , Such as :for、while、var.
  • Case sensitive

standard :

  • Variable names must have meaning
  • Follow the hump nomenclature . Initial lowercase , The first letter of the following words needs to be capitalized . for example :userName、userPassword

1.2.2 Exchange variables

//1. Use third-party variables for redeposit
var temp;
var num1 = 10, num2 = 5;
temp = num1; // temp:10, num1=10, num2=5
num1 = num2; //temp:10,num1=5,num2=5
num2 = temp; // temp:10,num1=5,num2=10
//2. Do not use third-party variables for variable exchange
var num1 = 10, num2 = 5;
num1 = num1+num2; // num1=15,num2=5
num2 = num1-num2; // num1=15,num2=10
num1 = num1-num2; // num1=5,num2=10
//3. utilize js High level syntax for variable exchange
var num1=10,num2=5;
[num1, num2] = [num2, num1]

1.2.3 data type

Basic data type :

  1. Numbers (number) type :Infinitiy( infinity )、-Infinitiy( An infinitesimal )、NaN: not a number( The digital )
  2. character string (string) type
  3. Boolean (boolean) type :Boolean Literal : true and false, Case sensitive ; Computer internal storage :true by 1,false by 0
  4. undefined type ( Unknown type ): Represents a variable declared with no assignment , When variables are declared only, the default value is undefined
  5. null: Means an empty , If you want the value of the variable to be null, Must be set manually
  6. symbol(ES6 newly added )

Reference data type :

objct:Array、function etc.


JavaScript Basics -- Hyperdetail ( Operator )_m0_48651355 The blog of -CSDN Blog

Please bring the original link to reprint ,thank
Similar articles

2021-11-25

2021-11-25

2021-11-25

2021-11-25

2021-11-25

2021-11-25

2021-11-25