云计算作业三+笔记

文章展示了JavaScript中的基础编程概念,包括函数定义(如getSum,tz),循环结构(for循环),日期时间操作,字符串操作(concat,replace,slice等),以及箭头函数和递归的简单应用。
摘要由CSDN通过智能技术生成
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        function getSum() {
        let sum = 1
        for(let i in arguments){
            sum *=arguments[i]
        }
        return sum
        }
        console.log(getSum(1,5,6,9))
    </script>
</body>
</html>

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
            for( a = 1;a<=100;a++){
            if(a % 7 == 0 ||a % 10 == 7|| parseInt(a / 10) ==7){
                console.log(a);
            }
        }
    </script>
</body>
</html>

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        function tz(n){
            if(n <= 3) {
                return 1;
            }else{
                return tz(n - 3) + tz(n - 1);
            }
        }
        console.log(tz(20))
    </script>
</body>
</html>

笔记

需要定义未知量

new date ()  获取当前时间

(包括年月日等等)

Date获取当前时间的时间对象

获取当前年份

Date.getfullyear()

获取当前月份

Date。Getmonth()+1

获取当前日

Date。Getdate()

获取当前时

Date.gethours ()

获取当前分

Date.getminutes ()

获取当前秒

Date.getsecond()

获取当前星期几

Date。Getday()

获取当前毫秒数

Date.Getmilliseconds()

获取时间戳
date.gettime()

字符串对象

连接字符串

方法一:Str3=Str1.concat(str2)

Str3.match(/\d/g)

使用正则替换原来的内容

Sfr3.replace(/a/g,”(需要换东西)”)

截取

Str3.Slice(序列,序列)

分割(以参数进行分开)

Split(“参数”)

用。。。拼接

Join(“参数”)

转大写,转小写

名字倒写

函数

一段独立功能的代码的集合

引入自定义函数的基本架构

同C语言一致

在函数没有return下,默认返回undefined

作用域

Arguments 用于承接用户发出数据

匿名函数

箭头函数

同上面一个意思

递归:自己调用自己

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值