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.
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.
In JavaScript, the this keyword refers to the object that is currently executing the code. The short version of what this evaluates to is as follows: By default, this refers to the global object. In a function, when not in strict mode, this refers to the global object.
A JavaScript function is defined with the function keyword, followed by a name, followed by parentheses (). Function names can contain letters, digits, underscores, and dollar signs (same rules as variables). The parentheses may include parameter names separated by commas: (parameter1, parameter2, ...)
Defining a Function Functions are defined, or declared, with the function keyword. Below is the syntax for a function in JavaScript. The declaration begins with the function keyword, followed by the name of the function.
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.
Have a look at
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With