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

Summary of basic JavaScript knowledge (2) Introduction, variables, value types, operators

php中世界最好的语言
Release: 2018-03-10 11:48:09
Original
1511 people have browsed it

This time I will bring you a basic JavaScript knowledge summary. There are a total of eleven knowledge points. Basic JavaScript knowledge summary (2) introduction, variables, value types, operatorsThe following is a practical case, let’s take a look.

Start a formal review of JS

What are the mainstream browsers

Mainstream browsers

Kernel

IE trident

Chrome webkit/blink

firefox Gecko

Opera presto

Safari webkit

How to introduce JS?

Page inline< ;script type="text/javascript">tag

External introduction

is in compliance with Web standards (One of the w3c standards) Structure, style, and behavior are separated, usually using external references

Structure Behavior style

html js css

Separation: three The files are written separately, development standards

JS basic syntax

Variable (variable)

Declaration, assignment decomposition

Single var

Variable Statement

Naming rules

Variable names must start with English letters, _, $

Variable names can include letters, _, $, and numbers

No You can use system keywords and reserved words as variable names

Query keys or reserved words

Declare variables

//声明一个变量var a;
//声明多个变量var a = 100,
    b = 200,
    c = "holle world";
Copy after login

Basic syntax

Original value (stack Data): Number Boolean String undefined null (immutable original value)

Reference value (heap data): array Object function...date RegExp, etc.

//Several types of original values //Number type, number type var a = 111; //String type, string type var b = "I am super handsome" //Boolean type has two values, one true and one false var c = true; var d = false;/ /The undefined type is just one value unedfinedvar e = unedfined;//The null type represents the site and represents empty

When the computer saves the value, the original value and the reference value are stored in different places. The original value is stored in In the stack (stack), the reference value is roughly stored in the heap (heap);

//原始值 栈var a = 10,var b = a;
 a = 20; //打印出b-->10;
//引用值 堆//例子一var arr = [1,2];var arr1 = arr;
arr.push(3);//打印出arr1-->[1,2,3];//例子二var arr = [1,2];var arr1 = arr;
arr = [1,3];//打印出arr1-->[1,2];
Copy after login

The difference between js stack and heap

Basic rules for JS statements

To be used after the statement The semicolon ends with ";".

JSSyntax error will cause subsequent code to terminate, but will not affect other JS code blocks

The writing format must be standardized, "=, +, -, /" There should be spaces after

function demo(){}. There is no need to add a semicolon after the function. There is no need to add a semicolon after the

for(){}.

if( ){} does not need to be followed by a semicolon

//JS syntax errors will cause subsequent code to terminate, but will not affect other JS code blocks

<script type="text/javascript">console.log(a);<script><script type="text/javascript">var b = 1;console.log(b);<script>//
Copy after login

The first part of the code block will report an error directly, but Does not affect the printing of the second part b;

JS operator

JS Numbr default floating point type

Arithmetic operator

Mathematics Operations, string linkage

Any data type plus string is equal to string

"+"

"-", "*", "/", "=", "()"

"++", "--", "+=", "-=", "/=", "*=", "% =”;

Priority “weakest”, “()” highest

JS addition, subtraction, multiplication and division

//加var a = 10,
    b = 20,
    c,
    e,
    g,
    h,
    f;
    c = a + b;//加 打印30
    f = 1 + "a"; //字符串拼接 打印"1a"
    e = b - a;//减 打印20
    g = a*b;//乘 打印200
    h = b/a;//除法 打印2var num = 0/0//打印NaN  全称Not A Number  计算机知道是数字但是显示不出来用NaN表示 叫非数  是Numbar类型
var a = 10;var b = 10;
a++;//打印a-->11;b--;//打印b-->9;a += 10//等于a = a + 10,打印a-->20a += 10 + 1//等于a = a + 10 +1 打印a-->21//*=、/=相似 不做介绍
Copy after login

To be continued. . . . Next chapter Logical Operator, Computational Operator

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!

Related reading:

Basic JavaScript knowledge summary (1)

VUE’s calculated properties and listener usage Case

vue life cycle, vue instance, template syntax

The above is the detailed content of Summary of basic JavaScript knowledge (2) Introduction, variables, value types, operators. 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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!