In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces the relevant knowledge of javascript object-oriented programming, the content is detailed and easy to understand, the operation is simple and fast, and it has a certain reference value. I believe you will gain something after reading this javascript object-oriented programming knowledge point. Let's take a look at it.
Definition and use of function
The content of this section is mainly on the previous Jquery review, review: the definition of the function, the method of calling the function.
This pointing to the problem
The main content of this module is to learn who the object this points to in different functions and how to change the pointing method of this inside the function: call, apply, bind.
Change the pointing method of this inside the function: call, apply, bind.
These three methods have something in common: they can all change the direction of this.
These three methods are different:
Call and apply will call the function and change the this inside the function to point to
The parameters passed by call and apply are different. The parameters passed by call are separated by commas, and apply are passed by arrays.
Bind does not call the function, but can change the point of the this inside the function.
Strict mode
The main content of this module is to learn to understand what strict mode is.
Strict schema definition: ES5's strict schema is a way of using restrictive JavaScript variants to run JS code under strict conditions. Strict mode is only supported in browsers above IE10 and ignored in older browsers. )
Turn on strict mode:
Turn on strict mode for scripts
Turn on strict mode for the function.
Higher order function
The main content of this module is to learn the definition and related applications of higher-order functions.
High-order function definition: a higher-order function is a function that operates on other functions, receiving a function as a parameter or outputting a function as a return value.
The best thing to understand is the callback function, which is a higher-order function.
Closure
The content of this module is mainly to learn the definition of closure, the function of closure, the application of closure.
Closure definition: a closure refers to a function that has access to variables in the scope of another function. The simple understanding is that one scope can access local variables within another function.
Closure function: extends the scope of the variable.
Use of closures:
Click li to print the current index number
Var lis = document.querySelector (".nav"). QuerySelectorAll ("li"); for (var I = 0; I < lis.length; iTunes +) {lis.index = I; lis.onclick = function () {console.log (this.index) Definition of a closure: a function that has access to variables in the scope of another function. The simple understanding is that one scope can access local variables within another function. / / requirements: use closures to get the index number of li var lis = document.querySelector (".nav"). QuerySelectorAll ("li"); for (var I = 0; I < lis.length; iTunes +) {(function (I) {/ / console.log (I); lis.onclick = function () {console.log (I)) / / We only see I}}) (I);} when we click.
Print the contents of li after 3 seconds
Li index number var lis = document.querySelector (".nav"). QuerySelectorAll ("li"); for (var I = 0; I < pig) (function (I) {/ / this is the immediate execution function / / simply put the timer in the immediate execution function setTimeout (function () {/ / any function in the immediate execution function can call the variable console.log in the immediate execution function (lisi [I] [xss_clean])) }, 2000)} (I);}
Calculation and Application of Taxi Price
Var car = (function () {/ / execute function var start = 13; / / starting price var total = 0; / / Total price return {price: function (n) {if (n 0) {/ / 2. The object 11 12 in the traversal object can make use of the recursive function (call your own getID (object in the object item.goods,id)) / / there should be an array of goods and the length of the array is not 0 getID (item.goods,id);}});} getID (data, 1); getID (data, 2); getID (data, 11) Regular expression
The main content of this module is to learn the definition of regular expressions and the use of regular expressions in js.
This is the end of the article on "what are the knowledge points of javascript object-oriented programming?" Thank you for reading! I believe that everyone has a certain understanding of "what are the knowledge points of javascript object-oriented programming". If you want to learn more knowledge, 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.