


Summary of basic JavaScript knowledge (2) Introduction, variables, value types, operators
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";
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];
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>//
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//*=、/=相似 不做介绍
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!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



How to use WebSocket and JavaScript to implement an online speech recognition system Introduction: With the continuous development of technology, speech recognition technology has become an important part of the field of artificial intelligence. The online speech recognition system based on WebSocket and JavaScript has the characteristics of low latency, real-time and cross-platform, and has become a widely used solution. This article will introduce how to use WebSocket and JavaScript to implement an online speech recognition system.

Face detection and recognition technology is already a relatively mature and widely used technology. Currently, the most widely used Internet application language is JS. Implementing face detection and recognition on the Web front-end has advantages and disadvantages compared to back-end face recognition. Advantages include reducing network interaction and real-time recognition, which greatly shortens user waiting time and improves user experience; disadvantages include: being limited by model size, the accuracy is also limited. How to use js to implement face detection on the web? In order to implement face recognition on the Web, you need to be familiar with related programming languages and technologies, such as JavaScript, HTML, CSS, WebRTC, etc. At the same time, you also need to master relevant computer vision and artificial intelligence technologies. It is worth noting that due to the design of the Web side

WebSocket and JavaScript: Key technologies for realizing real-time monitoring systems Introduction: With the rapid development of Internet technology, real-time monitoring systems have been widely used in various fields. One of the key technologies to achieve real-time monitoring is the combination of WebSocket and JavaScript. This article will introduce the application of WebSocket and JavaScript in real-time monitoring systems, give code examples, and explain their implementation principles in detail. 1. WebSocket technology

Essential tools for stock analysis: Learn the steps to draw candle charts in PHP and JS. Specific code examples are required. With the rapid development of the Internet and technology, stock trading has become one of the important ways for many investors. Stock analysis is an important part of investor decision-making, and candle charts are widely used in technical analysis. Learning how to draw candle charts using PHP and JS will provide investors with more intuitive information to help them make better decisions. A candlestick chart is a technical chart that displays stock prices in the form of candlesticks. It shows the stock price

Introduction to how to use JavaScript and WebSocket to implement a real-time online ordering system: With the popularity of the Internet and the advancement of technology, more and more restaurants have begun to provide online ordering services. In order to implement a real-time online ordering system, we can use JavaScript and WebSocket technology. WebSocket is a full-duplex communication protocol based on the TCP protocol, which can realize real-time two-way communication between the client and the server. In the real-time online ordering system, when the user selects dishes and places an order

JavaScript and WebSocket: Building an efficient real-time weather forecast system Introduction: Today, the accuracy of weather forecasts is of great significance to daily life and decision-making. As technology develops, we can provide more accurate and reliable weather forecasts by obtaining weather data in real time. In this article, we will learn how to use JavaScript and WebSocket technology to build an efficient real-time weather forecast system. This article will demonstrate the implementation process through specific code examples. We

JavaScript tutorial: How to get HTTP status code, specific code examples are required. Preface: In web development, data interaction with the server is often involved. When communicating with the server, we often need to obtain the returned HTTP status code to determine whether the operation is successful, and perform corresponding processing based on different status codes. This article will teach you how to use JavaScript to obtain HTTP status codes and provide some practical code examples. Using XMLHttpRequest

With the rapid development of Internet finance, stock investment has become the choice of more and more people. In stock trading, candle charts are a commonly used technical analysis method. It can show the changing trend of stock prices and help investors make more accurate decisions. This article will introduce the development skills of PHP and JS, lead readers to understand how to draw stock candle charts, and provide specific code examples. 1. Understanding Stock Candle Charts Before introducing how to draw stock candle charts, we first need to understand what a candle chart is. Candlestick charts were developed by the Japanese
