Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the basic knowledge of JavaScript programming

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

What are the knowledge points of this article "what are the basics of JavaScript programming?" most people do not understand, so the editor summarizes the following, detailed contents, clear steps, and a certain reference value. I hope you can get something after reading this article. Let's take a look at this "what are the basics of JavaScript programming" article.

Insert code into the page

Use. Js file

Because the JavaScript language is interpreted, it theoretically runs anywhere on the HTML page, but usually before the end of the body tag.

This is similar to the use of CSS3, which can be embedded directly in a HTML file or as a separate file, which can be called through a link when needed.

Data type

It is equivalent to simplifying the data type, there is no complex definition of floating-point shaping, long shaping, double precision, etc., 6 data types are all-inclusive, which is very good.

Variable definition

This is more nice, complicated into simple, all need to use: var keyword will be fine

It is important to note that:

Variable names are case sensitive A var defines only one variable and can only put one JavaScript statement per row

Typeof () function

There are only six results returned, which is so different from the six basic data types.

Data types are: null, and the returned results are: function

Data type conversion

Cast:

Boolean ()

Number ()

String () conversion function

ToString (): string

ParseInt (): integer

ParseFloat (): floating point number

Define

Function functionName (arg0,arg1, … , argN) {... } call

FunctionName (Parameter 1 assignment, Parameter 2 assignment, Parameter 3 assignment. ) function overloading

JavaScript does not support function overloading, but arguments.length can be used to detect the number of parameters of a function to achieve function overloading.

Anonymous function

Immediate definition, immediate use, immediate destruction and release

Return value

Can be any data type, use the return statement to return the value of the function and exit the function, there is no explicit return value, or the return statement with no value is called, the return value of the function is undefined

Object object

Object is the base class for all objects, and you can attach properties and methods through function

Var myObject1=new Object ()

Var myObject2= {}

These two ways are equivalent to built-in objects.

Math object: used to handle mathematical operations, including Date objects such as absolute values of various functions, trigonometric functions, random numbers, etc.: deal with date and time, get time and set time RegExp object: regular expression match, read emphatically when learning python crawler before, do not elaborate on Array object: array object, can nest various types, dynamic array, length is variable String object: string object You can manipulate Window objects such as sharding, matching, etc.:

(1) various dialogs:

Window.alert (warning dialog), window.confirm (confirmation dialog), window.prompt (dialog box that prompts the user for input)

When you use it, you can remove window and directly use: alert, confirm, prompt

(2) interval

SetInterval (function name or statement, millisecond interval): automatically executes a function or other statement at regular intervals

ClearInterval (interval id): terminates the above automatic command

(3) delay

SetTimeout (function name or statement, millisecond interval)

ClearTimeout (delay id): similar to interval

Custom class or object

Prototype attribute

Each object has this property, and you can add or override methods for the object

Hybrid constructor / prototype approach to implement custom classes

This keyword

When there is a new keyword, function must be the constructor of the class. When Student is used as a general function, this points to the window object, while when it is used as a constructor, this points to the Student object. In the constructor, the this keyword must be added before the properties of the class.

The data is a key / value pair. The data is separated by commas. Curly braces save object square brackets save array

JSON.parse (): deserializes to a JSON object

JSON. Stringify (): serialize to a string

The above is about the content of this article on "what are the basics of JavaScript programming?" I believe we all have a certain understanding. I hope the content shared by the editor will be helpful to you. If you want to know more about the relevant knowledge, please 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.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report