Original blog :https://blog.csdn.net/yaojxing/article/details/72784774
1. Common scenarios for anonymous functions
js Anonymous functions in are a very common type of functions , More common scenarios :
- <input type="button" value=" Click on " id="btn">
- <script type="text/javascript">
- // The first case of anonymous functions
- var btn=document.querySelector("#btn");
- btn.onclick=function(){
- // alert("aaaaa");
- }
- // The second case of anonymous functions
- setInterval(function(){
- // alert("bbbbb");
- }, 1000);
- // The third case of anonymous functions
- var fun=function(){
- alert("ccccc");
- }
- // fun();
- // The fourth case of anonymous function
- var obj={
- name:"dddd",
- say:function(){
- alert(this.name);
- }
- }
- obj.say();
- </script>
The above shows the common use scenarios of anonymous functions .( Be careful :querySelector yes H5 New search in dom Element method )
2. Anonymous self executing function
- <input type="button" value=" Click on " id="btn">
- lt;script type="text/javascript">
- //1, The first way to implement anonymous functions
- (function(data){
- // alert(data);
- })("eee");
- //2. The second implementation of anonymous self executing function
- (function(){
- // alert("fff");
- }());
- //3. The third way to implement anonymous self executing functions
- !function(data){
- // alert(data);
- }("hhh");
- //4. The fourth way to implement anonymous self executing functions
- var fun=function(data){
- alert(data);
- }("iii");
3. The role of anonymous self executing functions
4, Summary of anonymous functions and anonymous self executing functions
JavaScript Anonymous self executing function ~function(){} More articles about
- understand javascript The immediate execution function in (function(){})()
I saw a lot of code before , It's useful to write this function , But I didn't seriously think about why I wrote like this , Today I want to learn jquery Source code , Find out jquery It's the same way , use (function(window, undefine ...
- javascript The immediate execution function in (function(){…})()
javascript The immediate execution function in (function(){…})() In depth understanding of javascript The immediate execution function in , Immediate function is also called immediate function , Usually it's written in (function(){…})() package ...
- js Advanced use of closures in anonymous self executing functions (---------------------------******-----------------------------)
Let's first look at the most common problem : <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> ...
- js Anonymous functions and anonymous self executing functions in
1. Common scenarios for anonymous functions js Anonymous functions in are a very common type of functions , More common scenarios : <input type="button" value=" Click on " id ...
- js Anonymous self executing function
Anonymous self executing function : Function closures without method names : A closure is a function that has access to another function scope variable : Explain with an example : I found a case on the Internet , Used for loop . Anonymous self executing function .setTimeout. Case study 1: va ...
- JavaScript Function declaration , Function expression , The difference between anonymous functions , Deep understanding of immediate execution functions (function(){…})()
function fnName(){xxxx}; // Function declaration : Use function Keyword declares a function , In specifying a function name . // for example :( normal , because promote The function declaration , Function calls can precede function declarations ) f ...
- javascript Immediate execution function (function(){})()
See a piece of code : (function(){ var outer = $('#subject'); outer.find('li').on('mouseover', mouseover); })() ( ...
- In depth understanding of javascript The immediate execution function in (function(){…})()
contribute :junjie typeface :[ increase Reduce ] type : Reprint Time :2014-06-12 I want to comment on This article mainly introduces the in-depth understanding of javascript The immediate execution function in , Immediate function is also called immediate function , Usually it's written as ...
- Javascript The basic concept of function + Anonymous immediate execution function
Function declaration . Function expression . Anonymous functions Function declaration :function fnName () {…}; Use function Keyword declares a function , Specify another function name , It's called function declaration . Function expression var fnName = f ...
Random recommendation
- iOS 2D Drawing details (Quartz 2D) And Transform(CTM,Translate,Rotate,Scale)
Preface :Quartz By default, device independent user space To draw , When context( Drawing board ) After establishment , The default coordinate system origin and direction are also confirmed , Can pass CTM(current transformation ...
- pptp vpn
webalizer It's an efficient . Free of charge web Server log analyzer . The results are as follows HTML File format save , So it's very convenient to pass through web Server browsing ; http://daliang1215.iteye.com/ ...
- Teach you to remember ASP.NET WebForm The life cycle of a page
about ASP.NET Webform The developer of the , understand ASP.NET Webform The life cycle of a page is very important . The main purpose is to find out where to place specific methods and when to set various page properties . But the memory and understanding page life cycle provides ...
- 03C# Basics (2)
1. Comparison operator == be equal to ; != It's not equal to ; > Greater than ; >= Greater than or equal to ; < Less than ; <= Less than or equal to ; Comparison operator ( Also known as relational operators ) It's used to judge whether it's true or false , The result is boo ...
- hdu5323 Solve this interesting problem( Explosive search )
Reprint please indicate the source : http://www.cnblogs.com/fraud/ ——by fraud Solve this interesting problem Time Limit ...
- GCD Asynchronous synchronization experience
The previous blog post also wrote about synchronous and asynchronous , It might be reading other people's blogs , I don't have an experiment , I don't understand very well , So I typed some code to compare the serial . Parallel corresponding synchronization . asynchronous . 1. First, create a serial . Parallel thread queue 1 2 dispatch_queu ...
- spring mvc Cross domain solutions for
What is cross-domain In a word : The same ip. The same network protocol . Same port , All three are satisfied in the same domain , Otherwise, it's cross domain . Why cross domain Based on two aspects : a. web The application itself is deployed on different servers b. From a development perspective -- ...
- wet download jdk 64 position
wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com% ...
- Python3 The fifth in the actual combat series ( Get India after sales data project )
problem : Continue with the previous one . Let's do it , Write the program diligently ! The goal is : In this article, we try to put python The program is packaged into .exe Program . So you can run it on the server . The second step to realize the first plan list function module : 2. take python Program to ...
- Pairing projects junit The test case
subject : Let's say we're going to write a class of integer division , And write him test cases . Pairing division of labor : Teng Juan is responsible for writing the code , Data collection , Arrangement , Pan Guangmei is responsible for the test , Processing test results github Address Links : https://github.com/ ...