1024programmer JavaScript How to understand the concept of functions in javascript

How to understand the concept of functions in javascript

Grammar format:

function functionname()
 {
     // execute code
 }

function is a keyword used to define a function.

Note: Javascript is case sensitive. The keyword function must be lowercase, and the function must be called with the same case as the function name.

Function with parameters

Grammar format:

function myFunction(var1,var2)
 {
 the code
 }

Example:

A parameter with a return value

The return value is realized by the return statement .

Grammar format:

function myFunction()
 {
     var x=5;
   return x;
 }

Note: Using the return statement does not mean that the entire Javascript stops executing, only the function. Javascript will continue to execute the code from where the function was called.

Example:

Recommended tutorial: js introductory tutorial

The above is how to understand the details of the function concept in Javascript, please pay attention to 1024programmer for more .com Other related articles!

This article is from the internet and does not represent1024programmerPosition, please indicate the source when reprinting:https://www.1024programmer.com/how-to-understand-the-concept-of-functions-in-javascript/

author: admin

Previous article
Next article

Leave a Reply

Your email address will not be published. Required fields are marked *

Contact Us

Contact us

181-3619-1160

Online consultation: QQ交谈

E-mail: [email protected]

Working hours: Monday to Friday, 9:00-17:30, holidays off

Follow wechat
Scan wechat and follow us

Scan wechat and follow us

Follow Weibo
Back to top
首页
微信
电话
搜索