当前位置:网站首页>JS foundation 2
JS foundation 2
2022-06-28 10:53:00 【Programmer community】
function : Encapsulation of a piece of code , It is mainly used to realize a certain function ( Function is the embodiment of code encapsulation and reuse )
Definition
declarative function Function name (){ The body of the function } call : Function name ()
notes : Functions do not actively execute , Need to call
expression let|var Function name =functtion(){ The body of the function } call : Function name ()
notes : Declarative calls can be made before a function is defined , Expressions cannot
Definition of functions with parameters
Implement known data function code
In the parentheses that define the function , Fill in formal parameters , Multiple are separated by commas
Fill in the arguments in the parentheses of the calling function
Relationship between formal and actual parameters
Formal and actual parameters are in number , The order , Data types should be consistent
If the argument is less than the formal parameter , The parameter value is undefined
Variable scope
Global variables : Global availability . The function passes through var Defined , Or variables defined directly without keywords inside the function body
local variable : Variables defined inside a function body
The return value of the function
When you need the result of the function for the next operation , The return value is required when the return is explicitly required function Function name (){ The body of the function return Variable , value , expression ;} call : Function name ()
notes :return Once executed , Later code will not be executed ,
Function if not return, So the return value of the function is underfined
precompile
Function before line by line execution , Will precompile first
Variable Promotion : Promote the code declared by the variable to the front of the scope
- var Variables defined
- Declaratively defined functions
- return Subsequent statements
- if Inside the sentence ( Even if the conditions don't hold , It will also increase the variable )
arguments
- Function's own object : Record the correlation of function parameters
- Get the number of function arguments arguments.length
- Get a specific argument arguments[ The index of the corresponding argument ]
notes : Index from 0 Start
Recursive function
Recursive function : The function calls itself
notes : Recursion must have an end
Common events
- Get element node
document.getElementById('id name ') - Get element properties
Element nodes . Property name - Set element properties
Element nodes . Property name = Property value - The binding event
Element nodes .on Event type =function (){ To execute code }
Common event types
| event | meaning |
|---|---|
| onclick | Click on |
| onlode | Page loading complete |
| onmouseover | Mouse hovering |
| onmouseout | Mouse removal |
边栏推荐
- Katalon framework tests web (XX) custom keywords and upload pop-up operations
- Datetime and logging module
- File的io流与base64
- Six fusion positioning technologies in wireless communication application of Internet of things
- JSON module, hashlib, Base64
- 数据库系列:有什么办法对数据库的业务表进行无缝升级
- Guangzhou Customs supports the stable supply of food, agricultural products, traditional Chinese medicine and other civilian and biological resources to Hong Kong
- 广州海关支持保障食品、农产品和中药材等民生物资稳定供港
- Mysql database overview and installation process
- Mongo database
猜你喜欢

Debug debugging in katalon

【monkey】monkey测试入门

linux中源码安装mysql数据库(centos)

一款自动生成单元测试的 IDEA 插件,开发效率提升 70% 以上!

Markdown -- basic usage syntax

Remote connection of raspberry pie in VNC viewer mode without display

ruoyi集成积木报表(nice)

Fastposter v2.8.4 release e-commerce poster generator

AGCO AI frontier promotion (6.28)

数据库系列:有什么办法对数据库的业务表进行无缝升级
随机推荐
使用 ABAP 操作 Excel 的几种方法
Ble Bluetooth module nrf518/nrf281/nrf528/nrf284 chip scheme comparison
还在用 SimpleDateFormat 做时间格式化?小心项目崩掉!
MySQL(二)
AQS理解
Bytecode proof in appliedzkp zkevm (9)
Fabric. How to use js brush?
Remote connection of raspberry pie in VNC viewer mode without display
Mongo database
Oracle 日期格式化异常:无效数字
Redis数据库
如何利用k线图做技术分析
Décompression par compression
fastposter v2.8.4 发布 电商海报生成器
How to use dataant to monitor Apache apisex
Knowing the details of redis RDB, you can step on many holes less
BLE蓝牙模块NRF518/NRF281/NRF528/NRF284芯片方案对比
【力扣——动态规划】整理题目1:基础题目:509、70、746、62、63、343、96(附链接、题目描述、解题方法及代码)
ruoyi集成积木报表(nice)
MySQL common commands for viewing database performance