JavaScript FUNCTION STRUCTURE for Absolute Beginners



JavaScript FUNCTION STRUCTURE for Absolute Beginners

JavaScript FUNCTION STRUCTURE for Absolute Beginners

Whenever you learn a concept, break it down and look at it’s structure, if it has any. Let’s have a look into structre of JavaScript function. A JavaScript function is a block of code designed to perform a particular task, ideally one task. This is how we declare a JavaScript function. Use function keyword, type function name, use parenthesis, open and close curly braces. In parentheses we provide parameters that pass data into function to process. Function is like a procedure – a set of statements that performs a task or calculates a value. Function can take some input and returns an output.

We have declared a function with the name person. It’s expecting two values – name and age. Then it is returning values of name and age. From function keyword to closing curly bracket, the whole thing is a function. Function call invokes function.

– Function Keyword (JS Reserved Word)

In function, we have got word function. Function is a JavaScript reserved word or keyword. There are many reserved words in JavaScript. In JavaScript you cannot use reserved words as variables, labels, or function names.

– Function Declaration

Function can be declared in many ways. Regular function declaration and arrow function declaration. And there are other ways.

– Function Name

Person or employee words are the names of functions in our example.

– Function Parameters

A function can take multiple values. Inside function we use these values to calculate something or output something using these values. In parentheses these are called parameters that a function is expecting or values that a function is receiving.

– Function Body

Inside curly braces, we have function body that has function statements and return statement. Inside function body we have code to be executed and a return statement.

– Return Keyword

Return is also a reserved word in JS. A JavaScript function should always return something. When JavaScript reaches a return statement, the function will stop executing. After return statement, nothing is executed.

– Function Arguments

JavaScript function is executed when it is invoked or when it is called. We call a function by using it’s name and then we use arguments in parentheses. Function arguments are the values provided to function when it is invoked.

– Benefit of a Function

By using functions, we can reuse code. We can define the code once, and use it multiple times. We can use the same code many times with different arguments, to produce different results.

When you look at the function like this and know it’s structure, it becomes easy for you to use it. In coming videos we will go deep into JavaScript functions, their types and usage.

✅ How To Hide / Protect JavaScript Code – Techniques and Tools
https://youtu.be/8VyzRlxo2-k
✅ React JS UNDEFINED Solution | Reactjs Learning | Learn ReactJS & JavaScript Debugging Fast
https://youtu.be/0IvxCxcEBPo
✅ Calculate Sum or Total from Values in Array & Array Object | Learn JavaScript | Reduce Method
https://youtu.be/Xw7G2b80dDg
✅ Get URL Parameters in JavaScript | URLSearchParams
https://youtu.be/CZP1iQFQjEY
✅ DIV to PDF, Iframe to PDF using JavaScript Only (with CSS & Images Support)
https://youtu.be/DV2tAG5E-F0
✅ How To UnMinify JavaScript Minified Files Easily | Decrypt Complex JavaScript Code
https://youtu.be/uh8_Rt4Qam8
✅ Toggle Class in Vanilla JavaScript | Learn JavaScript
https://youtu.be/IdtwowBlfmI
✅ How to Execute a JavaScript File by using NPM
https://youtu.be/2xcoenAdSWs
✅ Get User’s Location (Country, State, City) with Free Unlimited API Access | PHP & JavaScript
https://youtu.be/_P8_JUaoNgs
✅ Replace jQuery with Vanilla JavaScript Code Easily | jQuery vs JavaScript
https://youtu.be/toJ3vRUMf2g
✅ Toggle in Vanilla JavaScript
https://youtu.be/ebDCyf-JFOw
✅ MINIFY JAVASCRIPT FILES & FOLDERS in Multiple Ways (Command Line & Code Editor)
https://youtu.be/umVoV4ak0HA
✅ JavaScript vs jQuery | Difference between JavaScript and jQuery
https://youtu.be/PrBSuz7rPlc
✅ JavaScript Variable Redeclare & Reassign | VAR vs LET vs CONST | Practical Examples
https://youtu.be/9NNva3x0awQ

Thank You!
👍 LIKE VIDEO
👊 SUBSCRIBE
🔔 PRESS BELL ICON
✍️ COMMENT

Channel: https://www.youtube.com/webstylepress
Website: https://www.webstylepress.com
FaceBook: https://www.facebook.com/webstylepress
Twitter: https://twitter.com/webstylepress
GitHub: https://github.com/webstylepress
#WebStylePress #js #javascript #function #javascriptfunction #javascriptengineer #javascripttraining #javascriptinterviewquestions #programming #webdevelopment

Comments are closed.