Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Does JavaScript have a named function?

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly introduces the relevant knowledge of "there is no named function in JavaScript". The editor shows you the operation process through an actual case. The method of operation is simple and fast, and it is practical. I hope this article "JavaScript has named function" can help you solve the problem.

There are named functions in JavaScript. You can use the function keyword to declare a named function with the syntax "function function name (parameter list) {statement block to be executed;}"; the named function can be called before and after the named function declaration, and the function declaration will be automatically promoted to the top.

The operating environment of this tutorial: windows10 system, javascript1.8.5 version, Dell G3 computer.

Does JavaScript have named functions?

JavaScript has named functions

Function function name (argument list) {/ / function declares the block of statements to be executed by the keyword of the function;}

Function: keyword that defines the function (must be lowercase)

Function name: a custom name (the function must be called in the same case as the function name)

Function body: a piece of code to be encapsulated that can perform a specific function

Features: function declaration promotion, automatic promotion to the top

Function declarations can be called anytime, anywhere. A named function can be called before and after, and an anonymous function can only be called after the function.

The unit of JavaScript code is a function, which can contain a piece of executable code or accept parameters passed in by the caller. JavaScript mainly defines functions in the following ways:

The first way: name the function

Function function name (argument list) {/ / function declares the statement block of the function keyword to execute;} function myAge (age) {[xss_clean] ('my age is'+ age') / / my age is 19} myAge (19) / / the function is not called and not executed

The second kind: anonymous function

Function (parameter list) {/ / with reference function call the statement block to be executed by this function} / / anonymous function var a=function (age) {[xss_clean] ('my age is'+ age') / / my age is 19} a (19)

Unlike anonymous functions, named functions can be called before and after naming functions, and anonymous functions can only be called after the function.

This is the end of the content about "does JavaScript have named functions". Thank you for reading. If you want to know more about the industry, you can follow the industry information channel. The editor will update different knowledge points for you every day.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report