JavaScript_3th_函数
来源:互联网 发布:浙江理工大学 知乎 编辑:程序博客网 时间:2024/05/29 08:34
一、函数
JavaScript中的函数相当于Java中的方法,在JavaScript中使用function关键字来定义一个函数。
1)无参函数
1)有参函数
3)有返回值的函数
JavaScript中的函数相当于Java中的方法,在JavaScript中使用function关键字来定义一个函数。
1)无参函数
<!DOCTYPE html><html><head><meta charset="UTF-8"><title></title><script language="JavaScript">function test(){document.write("a");document.write("b");}</script></head><body><script language="JavaScript">test();</script></body></html>
1)有参函数
<!DOCTYPE html><html><head><meta charset="UTF-8"><title></title><script language="JavaScript">function test(a){document.write(a);}</script></head><body><script language="JavaScript">test("Hey Jude!");</script></body></html>
3)有返回值的函数
<!DOCTYPE html><html><head><meta charset="UTF-8"><title></title><script language="JavaScript">function test(y){return y * 3.14;}</script></head><body><script language="JavaScript">document.write(test(12.3));</script></body></html>
1 0
- JavaScript_3th_函数
- 函数
- 函数
- 函数
- 函数
- 函数
- 函数
- 函数
- 函数
- 函数
- 函数
- 函数
- 函数
- 函数
- 函数
- 函数
- 函数
- 函数
- Find Largest Value in Each Tree Row
- java 中一个char包含几个字节
- C/C++的一些知识点归纳(二)
- ACM程序设计书中题目--W(草地问题)
- 不同封装大小以及不同封装转换(会继续更新)
- JavaScript_3th_函数
- 【VB.NET视频】VB与VB.NET的区别
- new life
- MAC+WINDOWS 多系统 分区
- NLTK之搜索文本的相关入门函数(一)
- 编码/加密
- C++动态内存分配---allocator类的原理与实现(一)
- 第四周
- L2-008 链表去重(两种方法)