English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Use JSON to Define Functions, Where You Can Define Multiple Function Implementation Methods

As shown below:

  <script> 
 	//Normal Method
  	function add(a,b){
  		return a+b;
  	}
  	add(3,4);
  	//Defining functions using JSON, where multiple functions can be defined
  	var method={
  			add:function(a,b){
  				return a+b;
  			},
  			add2:function(a,b){
  				return a+b;
  			},
  			add3:function(a,b){
  				return a+b;
  			},
  	};
  	var temp = method.add2(31, 4);
  	alert(temp);
  </script>

This is the full content of defining functions using JSON, where multiple function implementation methods can be defined. I hope everyone will support and cheer for the tutorial~

You May Also Like