
js
哈喽沃德感叹号
这个作者很懒,什么都没留下…
展开
-
js语法5 面向对象2 继承相关
//定义一个类:定义函数对象,有一个成员prototype变量,这是一个{}空表 //new时,创建实例,也是函数对象,同时在该对象{}中会创建__proto__,这是复制了prototype中的方法 //a{__proto__: prototype} //实例化时,复制表的值 // function Point() { this.x = 0; this.y = 0; } //添加类的方法 Point.prototype.set_pos = function(x, y) { th.原创 2020-12-21 21:48:06 · 93 阅读 · 0 评论 -
js使用4 面对对象和模块
///////////模块/////////// 1、引用其他模块require a.如果是第一次调用,则加载并执行 b.每个模块由module.exports导出的对象 c.每次require时,都会返回module.exports //main.js var utils = require("./utils") //utils.js var utils = { num_PI: function() {return 3.14;} }; console.log("loa.原创 2020-12-16 23:01:46 · 121 阅读 · 0 评论 -
js语法3 高级使用
/////////Math工具函数///////// //1、π consle.log(Math.PI) //2、随机random()---> [0, 1) consle.log(Math.random()) //3、向下取整,Math.floor() //4、三角函数,反三角函数 Math.sin() Math.asin() Math.cos() Math.acos() Math.tan() Math.atan() //5、角度、弧度互换 //6、返回一个坐标对应的角度 Math.ata.原创 2020-12-13 21:38:10 · 108 阅读 · 0 评论 -
js语法2 表达式、条件、循环
///////////表达式////////// //加减乘除,() //++, --, +=, -=, *=, /= var a = 1 console.log(a ++);//输出1,a再加1 console.log(++ a);//a先加1,再输出2 //>, >=, ==, <, <=, != //&&, || //字符串加法:把基本数据类型,转换为字符串后,再连在一起 ///////////条件////////// if() {} else if{.原创 2020-12-13 20:41:31 · 125 阅读 · 0 评论 -
js语法1 基本数据和复杂数据
1、var定义一个变量,分配内存,但只够存基本数据类型、引用 数据类型 //整数、小数、逻辑变量---->简单数据对象=传递值 //字符串对象、数组对象、表、函数对象---->使用=传递是引用,变量指向该对象地址 undefine:变量没定义 null:一个变量不保存任何数据,初始化为null 2、[]数组 3、{}字典、表 var list_table = {0: true, hello: 3}; 访问: list_table.hello 或 list_ta...原创 2020-12-13 20:15:55 · 272 阅读 · 1 评论