當(dāng)前位置:
首頁 >
前端技术
> javascript
>内容正文
javascript
【JavaScript】04-js函数
生活随笔
收集整理的這篇文章主要介紹了
【JavaScript】04-js函数
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
04-js函數(shù)
函數(shù)的創(chuàng)建方式
1.函數(shù)的創(chuàng)建方式一
<script type="text/javascript">function hello() {console.log("hello");}//調(diào)用hello(); </script>2.函數(shù)的創(chuàng)建方式二
<script type="text/javascript">let hi = function() {console.log("hi");}//調(diào)用hi(); </script>3.有參的函數(shù),注意參數(shù)列表中的變量無需修飾符
<script type="text/javascript">function myPlus(a, b) {console.log("結(jié)果為:" + (a + b));}//調(diào)用myPlus(10, 18); </script>4.有參有返回值的函數(shù)
function play(t){console.log("上網(wǎng)打游戲!")return t * 5; } let money = play(10); console.log(money);總結(jié)
以上是生活随笔為你收集整理的【JavaScript】04-js函数的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。