In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article is to share with you what are the basic knowledge points of JavaScript. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
Introduction to JavaScript
JavaScript (Java script) is an interpretive scripting language based on object (Object) and event-driven (Event Driven) and has security performance. Its purpose is to add dynamic effect and interactive ability to the web pages of the client, and to realize a real-time and dynamic interactive relationship between users and web pages.
JS composition
JS composition: ECMAScript (the core of JS), DOM (document object model), BOM (browser object model)
ECMAScript: mainly defines the syntax of JS
DOM: a set of API,DOM that manipulates page elements can think of HTML as a document tree. The API provided by DOM can manipulate nodes on the tree.
BOM: a set of API that operates browser functions. Browser windows can be manipulated through BOM.
JS is mainly used for web special effects, server development, command line tools, desktop programs, APP, control hardware-Internet of things, game development JavaScript writing location
1. Write on the line
1 position / this is a true value
2 > = 3 position / this is a false value converted to a Boolean value
Null
Undefined
"
NaN
0
Note: Boolean values are often used in conditional sentences.
Typeof operator
Gets the variable type, and the returned value is of type string. The results are:
"undefined"
"boolean"
"string"
"number"
"object"
"function"
Typeof 10 / / "number"
Typeof "10" / / "string"
Function fn () {
...
}
Typeof fn / / "function"
/ / age is not declared
Typeof age / / "undefined"
Typeof null / / "object"
Typeof undefined / / "undefined" JavaScript object
1. Object object
The Object type, which we also call an object. Is a reference data type in JavaScript.
It is a compound value that aggregates many values together and can be accessed by name.
An object can also be thought of as an unordered collection of attributes, each of which is a name / value pair.
In addition to creating its own properties, objects can also inherit properties from an object called a prototype.
Except for strings, numbers, true, false, null, and undefined, the values in JS are all objects.
Creating objects there are two ways to create objects
The first kind:
Var obj = new Object ()
Obj.name = "#"
Obj.age = 15
The second kind:
Var obj = {
Name: "#"
Age:15
}
III. Access to object attributes
There are two ways to access properties: objects. Property name or object [attribute name]
IV. Array
Arrays are also a kind of objects. An array is a language structure used to express a set of sequentially related values.
Create an array = Note: different from the java array with variable length var users = new Array (3); users [0] = 3; users [1] = 9; users [2] = 5; users [3] = 999; the values in the array are called elements. Each element can be read quickly by index (subscript). An index is a zero-based integer.
Function
Function is a core concept for any language. Any number of statements can be encapsulated through the function, and can be called and executed anywhere and at any time. Functions in ECMAScript are declared by the function keyword, followed by a set of parameters and the function body. Syntax:
Function functionName (arg0,arg1...) {
Statement
}
Example:
Function sayHi (name,message) {
Alert ("Hello" + name+ "," + message)
}
SayHi ("ly", "how are you?"); / / function call
Some built-in functions
The function in the return value ECMAScript can be defined with or without a return value. When the function is finished, the results are not printed all the time. We expect the function to give me some feedback (such as the result of the calculation is returned for subsequent operations), which allows the function to return something. That is, the return value. The function returns a return value through return
Return value syntax:
/ / declare a function with a return value
Function function name (formal parameter 1, formal parameter 2, formal parameter.) {
/ / function body
Return return value
}
/ / you can receive this return value through a variable
Var variable = function name (argument 1, Ref 2, Ref 3)
The result of the function call is the return value, so we can manipulate the result of the function call directly.
Return value detailed explanation: if the function does not use the return statement, then the function has the default return value: undefined if the function uses the return statement, then the value followed by return becomes the return value of the function. If the function uses the return statement, but there is no value after return, then the return value of the function is also: after the undefined function uses the return statement, the function will stop and exit immediately after executing the return statement. That is, all other code after the return will not be executed.
The parameter ECMAScript doesn't care about the number of parameters passed or the data type of the parameter. The parameters in ECMAScript are represented by an array that can be accessed inside the function body through the arguments object. The arguments object is just like an array (not an Array instance)
Formal parameters and actual parameters:
Formal parameters: when declaring a function, in order to make the function more flexible, some values can not be fixed, for these unfixed values. We can set parameters to the function. This parameter has no specific value, but only plays a role in occupying a position. we usually call it a formal parameter, also known as a formal parameter. Actual parameters: if the formal parameters are set when the function is declared, then the corresponding parameters need to be passed in when the function is called. The passed parameters are called actual parameters, also called arguments. Var x = 5, y = 6
Fn (XBI y)
Function fn (a, b) {
Console.log (a + b)
}
The / / xmemy argument has a specific value. When the function is executed, it will copy a copy of XMagol y to an and b inside the function, and the value inside the function is the copied new value. Thank you for reading! This is the end of this article on "what are the basic knowledge points of JavaScript". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!
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.