Home > Web Front-end > JS Tutorial > body text

The basics you must know about JavaScript

php中世界最好的语言
Release: 2018-03-19 14:07:12
Original
1458 people have browsed it

This time I will bring you the basic knowledge that JavaScript must know. What are the basic knowledge that JavaScript must know. The following is a practical case. Let’s take a look.

The most important parts of scripting language:

Data type OperatorControl statement Array Method (function)

1. Basic knowledge

Keywords:The system defines meaningful names such as background link, etc.

Identifier: Set your own name such as class aa

Variable: can be regarded as a container for storing data. The name must start with a letter and is case-sensitive. It can be assigned multiple times after definition. Pass-by-value assignment.

Define aa var aa=1, bb=2; Add a comma in the middle and a semicolon at the end

Define and assign the value var aa = 123

Use aa

Six major data types of variables:

String string number boolean Boolean object object null empty undefined undefined

Constant :Fixed value

Scalar:Standard variable type, such as integer floating point type string type Boolean type

For example

Var 23 Replace aaa with variable

2. Control statement

1. Determine if

(expression) {Execute if the expression is true} else{Execute this}

When there are more than two execution options if(){ }

       else{} if(){}

       else{}

2. Match switch

(variable){ case "4": alert ();

break;

case "5": alert ();

break;

default: alert ( ; If the matching case is successful, the case will be executed until the end of the break. If there is no break, the next case will be entered until the break or end position is found. No case enters default.

Three kinds of pop-up windows

 

alert() alarm window

 confirm() selection box (the return value is true or false)

## prompt ("Prompt for input", "Default value of the input box") (The return value is the input content)

4. Operator

Arithmetic operator +  -  *   / ++  -- %Take the remainder   

 Assignment operator  =                                                                                                                                                                                           and type)

 Logical operators

 

&& and || or ! Non Ternary operation

symbol

Expression? String concatenation The strings are preceded by the addition of numbers. The strings are adjacent and converted into string addition

   1+1+“1”=“21” "1"+1+1="111"

String splitting

Separate quotation marks "ab" becomes "a"+"b" Add the string aa inside "a"+aa+ "b"

var idVal = "asd";
var str = "<p id="+idVal+"></p>"
Copy after login

I believe you have mastered the method after reading the case in this article. For more exciting information, please pay attention to other related articles on the php Chinese website! Recommended reading:

Basic knowledge of html in the front-end

Analysis of the front-end layout of well-known websites

Basic knowledge about front-end css

The above is the detailed content of The basics you must know about JavaScript. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template