Home > Web Front-end > JS Tutorial > Analyze dynamic parameter transfer and dynamic attributes of JavaScript.

Analyze dynamic parameter transfer and dynamic attributes of JavaScript.

怪我咯
Release: 2017-04-01 09:29:07
Original
1902 people have browsed it

Use the anonymous function (immediate execution of the function) in js to implement dynamic parameters or dynamically change the object Attributes. I used it once in a while, hoping to give a tip to friends who are looking for it.
All codes:

(function(){
			console.info('这是一个匿名函数,会立即执行。');
		})();
		
		function count(a, b){
			console.info(a+b);
		}
		
		//传入一个匿名函数
		count((function(){return 100;})(), 10);
		
		//设置一个匿名函数的属性
		var ob = {
			count : (function(){return 100;})(),
			name : 'xx'
		};
		
		console.info(ob);
Copy after login

The above is the detailed content of Analyze dynamic parameter transfer and dynamic attributes of JavaScript.. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template