Python Learning Journey DAY13

Source: Internet
Author: User

Javascript

JavaScript is a programming language, the browser has built-in JavaScript interpreter, so in the browser according to the JavaScript language rules to write the corresponding code, the browser can explain and make corresponding processing.

1. JavaScript code exists in form

1 <!--way one-to-2 <script type "text/javascript" src= "js file" ></script>3  4 <!--mode Two--5 <script type "Text/javascript" >6    JS code content  7 </script>

2. Where JavaScript code exists

    • In the head of HTML
    • The bottom of the body code block of HTML (recommended)

Because the HTML code is executed from top to bottom, if the JS code in the head is time consuming, it will cause the user to be unable to see the page for a long time, if it is placed at the bottom of the body code block, even if the JS code is time consuming, it will not affect the user to see the page effect.

1 such as: 2  3 <script src= "Https://www.gstatic.com/og/_/js/k=og.og2.en_US.iF4jnkQuaf0.O/rt=j/t=zcms/m=def/exm=in , Fot/d=1/ed=1/rs=aa2yrtv5-poc4ks9gtgrdy2ywuwisqz7-q "></script>4 <script>5     Alert (' 123 '); 6 </script>

3. Variables

    • Global variables
    • Local variables

The declaration of a variable in JavaScript is a very error-prone point, the local variable must start with a Var, and if Var is not used, the default is to declare the global variable

1 var name = "Seven"  # local variable 2 age =            # global variable

Note: comments//OR/* * *

4. Basic data type,

Numbers (number)

1 var page = 111; 2 var age = number (+); 3 var a1 = 1,a2 = 2, a3 = 3; 4 parseint ("1.2"); 5 parsefloat ("1.2");

Strings (String)

1 varName = "Wupeiqi";2 varName = String ("Wupeiqi");3 varAge_str = String (18);4  5 Common methods:6 Obj.trim ()7 Obj.charat (Index)8 obj.substring (start,end)9Obj.indexof (Char)TenObj.length

Boolean (Boolean)

1 var true ; 2 var false ; 3 var status = Boolen (1==1)

Arrays (Array)

1 varnames = [' Alex ', ' Tony ', ' Eric ']2 varnames = Array (' Alex ', ' Tony ', ' Eric ')3  4 Common methods:5 Add6 Obj.push (ele) Append7 Obj.unshift (ele) First insertion8Obj.splice (index,0, ' content ') to specify an index insert9 removed fromTen obj.pop () array trailing fetch One obj.shift () array header fetch A Obj.splice (index,count) array specifies the position after count characters -        - slices the Obj.slice (start,end) - Merging - NewArray = Obj1.concat (obj2) - Flip + Obj.reverse () -        + string of AObj.join (' _ ')) at length - Obj.length -   -   - Dictionary - varItems = {' K1 ': 123, ' K2 ': ' Tony '}

Serialization and deserialization

1 var items = {' K1 ': 123, ' K2 ': ' Tony '}23 s = json.stringify (items)      #序列化字典  45 m = Json.parse (s)         #反序列化

Undefined

1 undefined indicates no value defined 2 var name;

Null

1 NULL is a special value

5. Circular statements

1 varnames = ["Alex", "Tony", "Rain"];2  3  4 //array: Way One5  for(vari=0;i<names.length;i++){6 Console.log (i);7 Console.log (Names[i]);8 }9  Ten   One //array: Mode two A  for(varIndexinchnames) { - Console.log (index); - Console.log (Names[index]); the } -   - varnames = {"Name": "Alex", "age": 18}; -   +   - //Dictionary: Way One +  for(varIndexinchnames) { A Console.log (index); at Console.log (Names[index]); - } -   -   - //While Loop -  while(condition) { in     //Break ; -     //continue; to}

6. Conditional statements

1 //If condition statement2  3     if(condition) {4  5}Else if(condition) {6          7}Else{8  9     }Ten   One varname = ' Alex '; A varAge = 1; -   - //switch,case Statements the     Switch(name) { -          Case' 1 ': -Age = 123; -              Break; +          Case' 2 ': -Age = 456; +              Break; A         default : atAge = 777; -}

7. Exception Handling

1 Try {2  3 }catch(e) {4  5 }finally{6  7 }

8. Functions

1 declaration of a function2     functionfunc (Arg) {3         return true;4     }5          6 Anonymous Functions7     varFunc =function(ARG) {8         return"Tony";9     }Ten   One self-executing functions A(function(ARG) { - Console.log (ARG); -}) (' 123 ')

9. Object-Oriented

1 functionFoo (name,age) {2      This. Name =name;3      This. Age =Age ;4      This. Func =function(ARG) {5         return  This. Name +Arg;6     }7 }8  9 varobj =NewFoo (' Wu ', 18);Ten varret = obj. Func ("SB"); OneConsole.log (ret);

Python Learning Journey DAY13

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.