JavaScript Learn the basic grammar of notes. For students who are not familiar with JavaScript and are not familiar with the basic grammar of JavaScript , you can save it and take a look!
Various arithmetic operators , comparison operators ,logical operators ;
if else statement,switch statement ;
You can check the reference links at the end of the article.
The following contents are all different parts of JavaScript.
This article first talks about the differences in several details in the above content.
1. Congruence judgment
There is a congruence judgment === in JavaScript comparison operator, which is used to judge whether the value and type are both equal.
2.for/in loop
The for/in loop in JavaScript is a bit like the enhanced for loop in Java, but it is used
Traverse the properties of the object.
1
2
3
4
5
<strong>
var
person={fname:
"John"
,lname:
"Doe"
,age:25};
for
(x in person)
{
txt=txt + person[x];
}</strong>
Copy after login
Where x is the attribute name, person[x] is the value of the attribute.
3.With statement
With the With statement, when accessing the objectproperties and methods There is no need to repeatedly specify the reference object. In the With statement block, all properties and methods that are not recognized by JavaScript are related to the object specified by the statement block. Function: Create a default object for a program.
Format: with (){ } That is:
Example: When using write( related to Document object ) or writeln() method, the following form is often used:
1
document.writeln(”Hello!“);
Copy after login
If a large amount of data needs to be displayed, the same document.writeln() statement will be used multiple times. In this case, it can be like the following program , put all the statements with the Document object as the reference object into the With statement block, thereby reducing the number of statements.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
<!DOCTYPE html>
<html>
<head>
<title>withTest.html</title>
<meta http-equiv=
"keywords"
content=
"keyword1,keyword2,keyword3"
>
<meta http-equiv=
"description"
content=
"this is my page"
>
<meta http-equiv=
"content-type"
content=
"text/html; charset=UTF-8"
>
<!--<link rel=
"stylesheet"
type=
"text/css"
href=
"./styles.css"
>-->
</head>
<body>
<script type=
"text/javascript"
>
with (document) {
write(
"您好 !"
);
write(
"<br>这个文档的标题是 : \""
+ title +
"\"."
);
write(
"<br>这个文档的 URL 是: "
+ URL);
write(
"<br>现在不用每次都写出 document对象的前缀了!"
);
}
</script>
</body>
</html>
Copy after login
4. Line break
You can use a backslash to break a line of code:
1
2
<strong>document.write("Hello \
World!");</strong>
Copy after login
But you can’t break the sentence like this: 1
document.write \(
"Hello World!"
);
Copy after login
The above is the content of the basic grammar of JavaScript learning notes. I hope it will be helpful to students. For more information, please search on this site!
Related recommendations:
javascript programming essentials_JS grammar dictionary_basic knowledge
Summarize 10 common methods in js syntax to improve coding efficiency
Manipulate JSON objects in Javascript and add simple implementations of deletion and modification
The above is the detailed content of Basic syntax of JavaScript learning notes. For more information, please follow other related articles on the PHP Chinese website!
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
Recommended: Excellent JS open source face detection and recognition project
Apr 03, 2024 am 11:55 AM
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
PHP and JS Development Tips: Master the Method of Drawing Stock Candle Charts
Dec 18, 2023 pm 03:39 PM
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
Simple JavaScript Tutorial: How to Get HTTP Status Code
Jan 05, 2024 pm 06:08 PM
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
The relationship between js and vue
Mar 11, 2024 pm 05:21 PM
The relationship between js and vue: 1. JS as the cornerstone of Web development; 2. The rise of Vue.js as a front-end framework; 3. The complementary relationship between JS and Vue; 4. The practical application of JS and Vue.
What are the syntax and structure characteristics of lambda expressions?
Apr 25, 2024 pm 01:12 PM
Lambda expression is an anonymous function without a name, and its syntax is: (parameter_list)->expression. They feature anonymity, diversity, currying, and closure. In practical applications, Lambda expressions can be used to define functions concisely, such as the summation function sum_lambda=lambdax,y:x+y, and apply the map() function to the list to perform the summation operation.
How to get HTTP status code in JavaScript the easy way
Jan 05, 2024 pm 01:37 PM
Introduction to the method of obtaining HTTP status code in JavaScript: In front-end development, we often need to deal with the interaction with the back-end interface, and HTTP status code is a very important part of it. Understanding and obtaining HTTP status codes helps us better handle the data returned by the interface. This article will introduce how to use JavaScript to obtain HTTP status codes and provide specific code examples. 1. What is HTTP status code? HTTP status code means that when the browser initiates a request to the server, the service
The connection and difference between Go language and JS
Mar 29, 2024 am 11:15 AM
The connection and difference between Go language and JS Go language (also known as Golang) and JavaScript (JS) are currently popular programming languages. They are related in some aspects and have obvious differences in other aspects. This article will explore the connections and differences between the Go language and JavaScript, and provide specific code examples to help readers better understand these two programming languages. Connection: Both Go language and JavaScript are cross-platform and can run on different operating systems.
The AI era of JS is here!
Apr 08, 2024 am 09:10 AM
Introduction to JS-Torch JS-Torch is a deep learning JavaScript library whose syntax is very similar to PyTorch. It contains a fully functional tensor object (can be used with tracked gradients), deep learning layers and functions, and an automatic differentiation engine. JS-Torch is suitable for deep learning research in JavaScript and provides many convenient tools and functions to accelerate deep learning development. Image PyTorch is an open source deep learning framework developed and maintained by Meta's research team. It provides a rich set of tools and libraries for building and training neural network models. PyTorch is designed to be simple, flexible and easy to use, and its dynamic computation graph features make
See all articles