Javascript函数,我怎样才能开始理解它们? [英] Javascript functions, how can I start beginning to understand them?

查看:76
本文介绍了Javascript函数,我怎样才能开始理解它们?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我完全理解为了学习javascript我需要知道函数是如何工作的,我理解传递参数的基础知识,然后调用带有值的函数可能会将某些内容添加到一起等等。我读过无数篇文章关于功能以及书籍等,但我只是不知道如何使用它们以及何时应该使用等等,更高级的功能可能有4个参数并且正在进行不同的计算并返回被触发的各种值回到剧本只是让我很困惑。

I totally understand that in order to learn javascript I need to know how functions work, I understand the basics of passing in parameters and then calling the function with the values to maybe add something together, etc. I've read countless articles about functions as well as books, etc., but I just dont get how they are used and when they should be used, etc., the more advanced functions that have maybe 4 parameters and are doing different calculations and returning various values that get fired back into the script just totally confuses me.

我想知道的是,我怎么能克服这种困惑以及你可能拥有的任何智慧之词?我还要补充一点,我之前没有编程经验,并且花了最近两个月的时间经常撞墙,因为我无法理解javascript。

What I would like to know is first of all how can I overcome this confusion and also any words of wisdom you may have? I will also add that I have no prior programming experience and have spent the last 2 months frequently hitting my head off a brick wall as I just cant understand javascript.

推荐答案

编程中的函数类似于数学中的函数。他们接受一些输入并产生一个输出(好吧,有时他们没有,但他们某事)。它们非常适合组织代码,封装功能并避免在不同位置编写相同的代码( DRY )。

Functions in programming are similar to functions in math. They take some input and produce an output (well, sometimes they don't, but they do something). They are great to organize your code, encapsulate functionality and to avoid writing the same code at different places (DRY).

获取更多参数的函数不一定更复杂。

Functions taking more parameters are not necessarily more complex.

看看

  • Wikipedia - Function(programming)
  • MDC - JavaScript Guide
  • especially MDC - JavaScript Guide: Functions
  • MDC - JavaScript Reference: Functions and function scope

这篇关于Javascript函数,我怎样才能开始理解它们?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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