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

Analyze dynamic parameter transfer and dynamic attributes of JavaScript.

怪我咯
怪我咯Original
2017-04-01 09:29:071906browse

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);

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!

Statement:
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