摘要: 1 对象字面量 var hero = { name: '黄忠', weapon: '弓箭', equipment: ['头盔', '靴子', '盔甲'], blood: 100, attack: function () { console.log(this.name + ':射箭'); }, run 阅读全文
posted @ 2020-03-24 19:06 花木兰r 阅读(160) 评论(0) 推荐(0) 编辑
摘要: 求斐波那契数列Fibonacci中的第n个数是多少? 1 1 2 3 5 8 13 21... function getFib(n) { // 函数体 var n1 = 1; var n2 = 1; var n3; for (var i = 3; i <= n; i++) { n3 = n1 + n 阅读全文
posted @ 2020-03-24 18:50 花木兰r 阅读(207) 评论(0) 推荐(0) 编辑
摘要: 1: return 如果一个函数不需要返回值,可以不写return 当函数中不写return的时候,返回的是undefined return 后面可以什么都不跟,如果return后面什么都不跟,会返回undefined; 函数执行的过程中只要遇到return 后面的代码就不会再执行 function 阅读全文
posted @ 2020-03-24 18:45 花木兰r 阅读(133) 评论(0) 推荐(0) 编辑
摘要: 99乘法表 var str = ''; for (var i = 1; i <= 9; i++) { // 内层循环 控制每一行有多少个内容 for (var j = i; j <= 9; j++) { str += i + '*' + j + '=' + i * j + '\t'; } str + 阅读全文
posted @ 2020-03-24 18:20 花木兰r 阅读(129) 评论(0) 推荐(0) 编辑
摘要: 转换成字符串类型 1 toString()方法 var num = 18; var isRight = true; console.log(typeof num.toString()); console.log(typeof isRight.toString()); 错误的方式 null和undef 阅读全文
posted @ 2020-03-24 17:45 花木兰r 阅读(150) 评论(0) 推荐(0) 编辑
摘要: <!doctype html><html lang="en"><head> <meta charset="UTF-8"> <title>Document</title> <style> section { width: 80%; height: 200px; border: 1px solid pi 阅读全文
posted @ 2020-03-24 17:27 花木兰r 阅读(149) 评论(0) 推荐(0) 编辑
摘要: <!doctype html><html lang="en"><head> <meta charset="UTF-8"> <title>Document</title> <style> * { margin: 0; padding:0; } ul { list-style: none; } nav 阅读全文
posted @ 2020-03-24 17:19 花木兰r 阅读(123) 评论(0) 推荐(0) 编辑
摘要: <!doctype html><html lang="en"><head> <meta charset="UTF-8"> <title>Document</title> <style> img { /*animation:动画名称 动画时间 运动曲线 何时开始 播放次数 是否反方向;*/ anima 阅读全文
posted @ 2020-03-24 17:10 花木兰r 阅读(130) 评论(0) 推荐(0) 编辑
摘要: <!doctype html><html lang="en"><head> <meta charset="UTF-8"> <title>Document</title> <style> div { width: 224px; height: 224px; margin: 100px auto; po 阅读全文
posted @ 2020-03-24 16:58 花木兰r 阅读(148) 评论(0) 推荐(0) 编辑
摘要: <!doctype html><html lang="en"><head> <meta charset="UTF-8"> <title>Document</title> <style> section { width: 450px; height: 300px; border: 1px solid 阅读全文
posted @ 2020-03-24 16:44 花木兰r 阅读(149) 评论(0) 推荐(0) 编辑