我评论了我的问题 [英] I have commented my questions

查看:84
本文介绍了我评论了我的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

// finds age
	function findAge(dob) {
	   var personAge = 2018 - dob;
	   return personAge;
		}
			
	   var ageMike = findAge(1990);
			
			
			
// function calling function 		
	function retirementCheck(year) {
	   var age = findAge(year); 


          /*1. how this function call findAge(year) is working?
				 
         2. previous function block code runs inside this function?
	3. gets reference or copy or just go to that function and generate output 
            and return to this function?
				
	4. Is a previous block
			
	var personAge = 2018 - dob;
	return personAge;

         dob changed to year because i have year 
         parameter now?

	*/
				
				
	var retirement = 65 - age;
	console.log(retirement);
				
}
			
retirementCheck(1994);





我是什么尝试过:



我想知道被调用函数在另一个函数内是如何工作的以及参数如何工作



What I have tried:

I want to know how a called function is working inside another function and how parameter is working

推荐答案

retirementCheck(1994);



这将调用函数 retirementCheck 传递值1994. retirementCheck 函数通过参数名称<$ c引用该值$ C>年。然后它调用传递值的 findAge 函数。 findAge 函数计算年龄并将其返回给调用函数。



您可以在任何地方找到完整的详细信息Javascript书籍或教程。


This calls the function retirementCheck passing the value 1994. The retirementCheck function refers to that value by the parameter name year. It then calls the findAge function passing in the year value. The findAge function calculates the age and returns it to the calling function.

You can find full details in any Javascript book or tutorial.


这篇关于我评论了我的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆