In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-10 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article shows you how to understand the 14 basic JavaScript concepts, which are concise and easy to understand, which will definitely brighten your eyes. I hope you can gain something through the detailed introduction of this article.
Basic overview
Hello everyone! For today's post, I decided to give a brief introduction to the basics of JavaScript. It is designed for beginners and basically summarizes the main basic concepts, and you don't have to spend a lot of time reading everything.
The key is to provide you with all the key points and get you started faster. It is definitely not a complete guide. This is just part of the global map I'm building.
In addition, it can also be used as a reference guide for getting started. The occlusal size is described below.
1. Code structure
Simply put, JavaScript consists of a series of statements and semicolons.
A statement is like a sentence, but in code.
For example, this is a statement:
Alert ('Say hi')
Semicolons are not mandatory, and semicolons can be executed when there is a physical line break between the two. This is equal to a full stop.
Sometimes, however, newline characters do not guarantee that the statement has been completed. Use the + sign to act as a connector between lines.
For example:
Console.log ('This' + name +'is gibrish')
2. "use strict"
For a long time, JavaScript didn't have to worry about backward compatibility. Why? Because the release of features never overlap-until it overlaps.
In 2009, ECMAScript 5 (ES5) was released, and the new features modified some existing features. By default, changes are not applied unless they are enabled using "use strict"
Strict use must be placed at the top of the JavaScript code, otherwise it will not be applied.
Now, always "use strict", because we don't want to use an earlier implementation of JavaScript.
3. Variable
Variables are placeholders for information. You can think of it as a bucket for storing data.
Declare the variable and name it using the keyword let.
This will initialize it. You can assign a value to it using =
If you do not assign anything to it, the default setting is undefined-this means it is initialized, but there is absolutely nothing in the bucket. In short, it just means that it has never been set.
This is different from null, where with null, developers have to assign it manually. To some extent, it is actually admitting that your code has deliberately made sure that the bucket is empty, and you just didn't forget to populate it, or something went wrong in the process.
In earlier scripts, var was used. The way they behave affects the final output. I kind of wrote it here. If you are interested, please check it at any time.
4. Data type
Compared with other languages, there are not many data types in JavaScript. The following is a comprehensive list and its meaning:
(1) number
Let someNumber = 2984; someNumber = 29.84
The number does not have quotation marks. It's just an ordinary old straight number. You can handle both integers and floating-point numbers. The basic operator handles numbers.
There is also a special infinite number. You only need to do 1 stroke 0-so one divided by zero. This value is considered to be the largest number ever and cannot be regarded as a small result.
If you get NaN, you have encountered a calculation error. This also means that you have to operate on meaningless mathematical operations, such as dividing string text by numbers.
(2) large integers
In JavaScript, the maximum number it can execute is about 16 digits. In most cases, our application can survive fewer than 16 digits. However, sometimes we may need large numbers to use it, such as cryptography.
Create a BigInt by adding n to the end of the number.
Const someMassiveNumber = 123456789012345678901234567890n
(3) string
Strings are text variables, enclosed in quotation marks. You can use three types of quotation marks-"single quotation mark", "double quote" and "backtick"
There is no difference between double and single in JavaScript. Backquotes are used more to extend the functionality of strings and to embed variables using ${}.
For example:
Let cat = "Tibbers"; console.log (`Hi, ${cat} `)
If you use quotation marks in the above example, it becomes a normal string.
(4) Boolean type
Will print out correct or error
This is usually the result of some kind of comparison.
(5) Null value
It just means "no". Null pointer content that you will not see in other languages.
(6) undefined
Undefined simply means that the value has not been assigned. There's nothing fancy.
(7) object
Other types of data types are simple, so they are called primitives. Objects are things for which you can set up multiple projects.
5. Type conversion
Sometimes, for whatever reason, you need to switch between different types. This is how you operate.
Let someFakeBoolean = true; someFakeBoolean = String (someFakeBoolean); / / using String () will convert your variable into a stringlet someFakeNumber = "3872"; someFakeNumber = Number (someFakeNumber); / / using Number () will convert your string into a number
Note that converting random text to numbers doesn't work, and it usually doesn't make any sense. You will end with NaN
Boolean () converts any value to true or false output. Any "null" (for example, 0Query nullpaper undefined and NaN) will return false. Everything else will be returned to true
6. Operator
These operators are not specific to JavaScript, and most programming languages usually support them in the same way. Here is the list:
AND (&) OR (|) XOR (^) NOT (~) LEFT SHIFT () ZERO-FILL RIGHT SHIFT (> >)
When you use these operators, just say them out loud, and they will basically do what you want.
For example:
PrintLine (line, id) {if (line & id) {/ / if both exists, run this code}}
7. Compare
Consider a mathematical comparison. That's what this is:
Greater than / less than: a > brecom a
Greater than / less than or equal to: a > = bregory a / / do something
The arrowhead function is usually on one line, but with the help of Curl {}, multiple lines may appear
It looks like this:
Let cat = () > {/ / this is / / a multi-line / / example return someValue; / / is required. Can just be a straight return;}
When using curl {} with the arrow function, you also need to exit it using return.
The above is how to understand the 14 basic JavaScript concepts. Have you learned any knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.