Inexplicable JS Basic Learning!

Source: Internet
Author: User

JavaScript Basic components:

1,ECMASCRIPT:JS syntax criteria, basic variables, operators, functions, if statements, for statements, etc.

2,dom: Manipulate the element API on the Web page, such as the movement of the box, color change, carousel diagram, etc.

3,bom: API functionality in the Operations browser section

Alert statement:

1, pop up the warning box statement, mainly used to pop up the hint in the webpage.

Basic code:

<script type= "Text/javascript" >  alert (2345678) </script>

2, two ways of annotation;

1,/**/Multi-line comments

2,//Single-line comment

3, console output: Console.log ("")

4,prompt () Statement: User dialog box input.

  

<script type= "Text/javascript" >  var a = prompt ("Hello! ")   //dialog box  Console.log (a)//  output </script>

5, the name of the variable is the same as Python, but the use of hump body more

Data type:

Type viewing mode: typeof

1,number Number Type:

var a = 1234;

Console.log (typeof a)

2,string: String

var str = "123"

Console.log (typeof str)

3,boolean: Boolean values similar to Python

4,null: Empty Object

5,undefined: Variable not defined

6, operators need to be aware that only = = = This is to determine whether the data type and value are exactly the same

About splicing thief his mother disgusting!!! As long as there is a str, mate + is stitching

7, digital type conversion, strong turn on the good!!

8, Process Control!

1,if,if-else,if-else If-else:

  

var ji = 20;if (ji>10) {  console.log (JI)    }alert ("Baichi")
This is the simplest way to use only if it exists
var ji  = 20;if (ji>=20) {    console.log (' 2333 ')}else{    console.log (' JS is sb! ‘)}
Simple Application

if (true) {   //execute Operation}else if (true) {    //satisfies condition execution            }else if (true) {   //satisfies condition execution        }else{  //Satisfies condition execution}
is different from Python and needs to be added if to expand

2,&& and | | is equivalent to and and or python, so no explanation

3,switch need to focus on memory!

 

var sb = "js"    Swich (SB)//Condition {case    "JS":    console.log ("Awesome!") ") break    ;//need to be aware that you must break the case    " python ":    console.log (" You will die with a sense of logic ") break    , Case    " CSS ":    Console.log ("You're nuts!") ") Break    ;}

4,while cycle, basically the same, change is the condition and the loop body need to set up parentheses

5,do_while executes the do before executing the while loop.

6,for Cycle

<! DOCTYPE html>

  

Inexplicable JS Basic Learning!

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.