摘要: left: 50%; margin-left: -35px; letf设置为50%是盒子左边在中间线上,要使盒子水平居中,需要让盒子中间在中间线上 margin-left 负值向左移动半个盒子像素,盒子右边没有东西不能用margin-right使盒子向左移动 阅读全文
posted @ 2020-12-26 17:22 WP-WangPin 阅读(445) 评论(0) 推荐(0) 编辑
摘要: js回调函数 什么是回调函数 在JavaScript中一个函数可以作为另一个函数的参数,这个作为参数的函数就叫回调函数,以回调函数作为参数的函数叫做主函数 回调函数简单写法 //含有回调函数的函数function main(callback){…………//主函数逻辑callback(a,b,c……) 阅读全文
posted @ 2020-12-22 22:22 WP-WangPin 阅读(160) 评论(0) 推荐(0) 编辑
摘要: mongoose报错:DeprecationWarning: collection.ensureIndex is deprecated. Use createIndexes instead mongoose报错:(node:9716)DeprecationWarning: collection.en 阅读全文
posted @ 2020-12-04 21:51 WP-WangPin 阅读(132) 评论(0) 推荐(0) 编辑
摘要: 题目描述 在数组 arr 的 index 处添加元素 item。不要直接修改数组 arr,结果返回新的数组 示例1 输入 [1, 2, 3, 4], 'z', 2 输出 [1, 2, 'z', 3, 4] function insert(arr, item, index) { let array=[ 阅读全文
posted @ 2020-11-30 15:23 WP-WangPin 阅读(114) 评论(0) 推荐(0) 编辑
摘要: 题目描述 合并数组 arr1 和数组 arr2。不要直接修改数组 arr,结果返回新的数组 示例1 输入 [1, 2, 3, 4], ['a', 'b', 'c', 1] 输出 [1, 2, 3, 4, 'a', 'b', 'c', 1] function concat(arr1, arr2) { 阅读全文
posted @ 2020-11-30 15:19 WP-WangPin 阅读(113) 评论(0) 推荐(0) 编辑
摘要: 题目描述 删除数组 arr 第一个元素。不要直接修改数组 arr,结果返回新的数组 示例1 输入 [1, 2, 3, 4] 输出 [2, 3, 4] function curtail(arr) { let array=[...arr]; array.shift(); return array; } 阅读全文
posted @ 2020-11-30 15:15 WP-WangPin 阅读(138) 评论(0) 推荐(0) 编辑
摘要: 题目描述 在数组 arr 开头添加元素 item。不要直接修改数组 arr,结果返回新的数组 示例1 输入 [1, 2, 3, 4], 10 输出 [10, 1, 2, 3, 4] function prepend(arr, item) { let array=[...arr]; array.uns 阅读全文
posted @ 2020-11-30 15:12 WP-WangPin 阅读(357) 评论(0) 推荐(0) 编辑
摘要: 题目描述 删除数组 arr 最后一个元素。不要直接修改数组 arr,结果返回新的数组 示例1 输入 [1, 2, 3, 4] 输出 [1, 2, 3] function truncate(arr) { let array=[...arr]; array.pop(); return array; } 阅读全文
posted @ 2020-11-30 15:06 WP-WangPin 阅读(138) 评论(0) 推荐(0) 编辑
摘要: 题目描述 在数组 arr 末尾添加元素 item。不要直接修改数组 arr,结果返回新的数组 示例1 输入 [1, 2, 3, 4], 10 输出 [1, 2, 3, 4, 10] function append(arr, item) { let array=[...arr]; //数组解构 arr 阅读全文
posted @ 2020-11-28 17:56 WP-WangPin 阅读(160) 评论(0) 推荐(0) 编辑
摘要: 题目描述 移除数组 arr 中的所有值与 item 相等的元素,直接在给定的 arr 数组上进行操作,并将结果返回 示例1 输入 [1, 2, 2, 3, 4, 2, 2], 2 输出 [1, 3, 4] function removeWithoutCopy(arr, item) { for(let 阅读全文
posted @ 2020-11-28 17:50 WP-WangPin 阅读(91) 评论(0) 推荐(0) 编辑
摘要: 题目描述 移除数组 arr 中的所有值与 item 相等的元素。不要直接修改数组 arr,结果返回新的数组 示例1 输入 [1, 2, 3, 4, 2], 2 输出 [1, 3, 4] function remove(arr, item) { return arr.filter(x=>{ retur 阅读全文
posted @ 2020-11-28 17:41 WP-WangPin 阅读(85) 评论(0) 推荐(0) 编辑
摘要: 题目描述 计算给定数组 arr 中所有元素的总和 输入描述: 数组中的元素均为 Number 类型 示例1 输入 [ 1, 2, 3, 4 ] 输出 10 function sum(arr) { let sum=0; arr.forEach(x=>{ sum+=x; }); return sum; 阅读全文
posted @ 2020-11-28 17:38 WP-WangPin 阅读(294) 评论(0) 推荐(0) 编辑
摘要: 题目描述 找出元素 item 在给定数组 arr 中的位置 输出描述: 如果数组中存在 item,则返回元素在数组中的位置,否则返回 -1 示例1 输入 [ 1, 2, 3, 4 ], 3 输出 2 function indexOf(arr, item) { return arr.indexOf(i 阅读全文
posted @ 2020-11-28 17:34 WP-WangPin 阅读(681) 评论(0) 推荐(0) 编辑
摘要: res.writeHead(301, { //301为重定向即跳转,location为跳转的页面 Location: '/list' }); res.end(); 阅读全文
posted @ 2020-11-26 16:12 WP-WangPin 阅读(483) 评论(0) 推荐(0) 编辑
摘要: let formData = ''; //接受post参数 req.on('data', param => { //post分多次接受数据 formData += param; //将每次接受的数据拼接在一起 }); req.on('end', async () => { //数据接受完毕后执行的方 阅读全文
posted @ 2020-11-26 16:10 WP-WangPin 阅读(487) 评论(0) 推荐(0) 编辑
摘要: // 引用系统模块 const http = require('http'); // 创建web服务器 const app = http.createServer(); // 当客户端发送请求的时候 app.on('request', (req, res) => { // 响应 res.end('< 阅读全文
posted @ 2020-11-25 16:11 WP-WangPin 阅读(81) 评论(0) 推荐(0) 编辑
摘要: 开启mongoDB服务:net start mongoDB 关闭mongoDB服务:net stop mongoDB 连接mongodb const mongooes = require('mongoose'); //导入mongoDB模块 mongooes.connect('mongodb://l 阅读全文
posted @ 2020-11-22 23:19 WP-WangPin 阅读(90) 评论(0) 推荐(0) 编辑
摘要: 阅读全文
posted @ 2020-11-13 17:10 WP-WangPin 阅读(160) 评论(0) 推荐(0) 编辑
摘要: <!-- 网页说明 --> <meta name="description" content=""> <!-- 关键字 --> <meta name="keywords" content=""> <title>品优购</title> 阅读全文
posted @ 2020-11-13 16:35 WP-WangPin 阅读(145) 评论(0) 推荐(0) 编辑
摘要: <link rel="shortcut icon" href="favicon.ico"> 阅读全文
posted @ 2020-11-13 16:15 WP-WangPin 阅读(56) 评论(0) 推荐(0) 编辑
摘要: const Comepare = { LESS_THAN: -1, BIGGER_THAN: 1, EQUALS: 0 } function defaultCompare(a, b) { if (a b) { return Comepare.EQUALS; } return a < b ? Come 阅读全文
posted @ 2020-11-09 18:18 WP-WangPin 阅读(104) 评论(0) 推荐(0) 编辑
摘要: const map = new Map(); map.set('Gandalf', 'gandalf@email.com'); map.set('John', 'johnsnow@email.com'); map.set('Tyrion', 'tyrion@email.com'); console. 阅读全文
posted @ 2020-11-09 12:48 WP-WangPin 阅读(182) 评论(0) 推荐(0) 编辑
摘要: 一个良好的散列函数的构成有:插入和检索的时间(即性能),以及较低的冲突可能性。 djb2HashCode(key){ const tableKey = this.toStrFn(key); let hash = 5381; for (let i = 0; i < tableKey.length; i 阅读全文
posted @ 2020-11-08 22:28 WP-WangPin 阅读(97) 评论(0) 推荐(0) 编辑
摘要: 线性探查:当想表中的某个位置添加一个元素的时候,如果索引为position的位置已经被占据了,就尝试position+1的位置。如果position的位置也被占据了,就尝试position+2的位置,以此类推,直到在散列表中找到一个空闲的位置。 put(key, value) { if (key ! 阅读全文
posted @ 2020-11-08 22:17 WP-WangPin 阅读(287) 评论(0) 推荐(0) 编辑
摘要: 处理散列表中冲突的方法有:分离链接、线性探查和双散列法。 分离链接法:为散列表的每一个位置创建一个链表并将元素存储到里面。 相对于之前的散列表只需重写put、get和remove方法。 put(key, value) { if (key == null || value == null) { //键 阅读全文
posted @ 2020-11-07 21:52 WP-WangPin 阅读(176) 评论(0) 推荐(0) 编辑
摘要: 散列算法的作用是尽可能快地在数据结构中找到一个值。 散列函数的作用是给定一个键值,然后返回值在表中的地址。 class ValuePair { //用于存放一对键值对 constructor(key, value) { this.key = key; this.value = value; } to 阅读全文
posted @ 2020-11-07 10:43 WP-WangPin 阅读(111) 评论(0) 推荐(0) 编辑
摘要: 字典也称为映射、符号表或关联数组,在计算机科学中经常用来保存对象的引用地址。 集合以【值,值】的形式存放元素,字典是以【键,值】的形式存放元素。 class ValuePair { //存放一对键值的对象 constructor(key, value) { this.key = key; this. 阅读全文
posted @ 2020-11-06 18:10 WP-WangPin 阅读(257) 评论(0) 推荐(0) 编辑
摘要: let set = new Set(); function union(set1, set2) { //set1与set2的并集 let unionSet = new Set(); set1.forEach(element => { unionSet.add(element); }); set2.f 阅读全文
posted @ 2020-11-06 13:29 WP-WangPin 阅读(239) 评论(0) 推荐(0) 编辑
摘要: https://cloud.tencent.com/developer/chapter/13620 阅读全文
posted @ 2020-11-03 23:17 WP-WangPin 阅读(309) 评论(0) 推荐(0) 编辑
摘要: 阅读全文
posted @ 2020-11-03 22:40 WP-WangPin 阅读(200) 评论(0) 推荐(0) 编辑
摘要: class Set { constructor() { this.items = {}; } add(element) { if (this.has(element)) { return false; } else { this.items[element] = element; return tr 阅读全文
posted @ 2020-11-03 22:31 WP-WangPin 阅读(169) 评论(0) 推荐(0) 编辑
摘要: 阅读全文
posted @ 2020-11-03 21:57 WP-WangPin 阅读(188) 评论(0) 推荐(0) 编辑
摘要: class Node { //结点内部一个next指针一个元素数据 constructor(element) { this.next = null; this.element = element; } } class LinkedList { constructor() { //链表类属性为一个长度 阅读全文
posted @ 2020-11-03 16:30 WP-WangPin 阅读(110) 评论(0) 推荐(0) 编辑
摘要: function square(arr) { //为数组 arr 中的每个元素求二次方。不要直接修改数组 arr,结果返回新的数组 return arr.map(x=>x*x); } 阅读全文
posted @ 2020-11-02 21:48 WP-WangPin 阅读(159) 评论(0) 推荐(0) 编辑
摘要: function remove(arr, item) { //返回arr中和item不相同的值 return arr.filter(x=>x!==item); } 阅读全文
posted @ 2020-11-02 21:01 WP-WangPin 阅读(2071) 评论(0) 推荐(0) 编辑
摘要: 阅读全文
posted @ 2020-11-02 20:39 WP-WangPin 阅读(154) 评论(0) 推荐(0) 编辑
摘要: function sum(arr) { let count=0; arr.forEach(function(x){ count+=x; }) return count; } function sum(arr) { return arr.reduce((a,b)=>a+b,0); } 阅读全文
posted @ 2020-11-02 13:01 WP-WangPin 阅读(246) 评论(0) 推荐(0) 编辑
摘要: using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System. 阅读全文
posted @ 2020-11-01 21:52 WP-WangPin 阅读(145) 评论(0) 推荐(0) 编辑
摘要: //获取日期+时间 DateTime.Now.ToString(); // 2008-9-4 20:02:10 DateTime.Now.ToLocalTime().ToString(); // 2008-9-4 20:12:12 //获取日期 DateTime.Now.ToLongDateStri 阅读全文
posted @ 2020-11-01 18:17 WP-WangPin 阅读(2821) 评论(0) 推荐(0) 编辑
摘要: public Form1() { InitializeComponent(); System.Windows.Forms.Control.CheckForIllegalCrossThreadCalls = false;//设置该属性 为false } 阅读全文
posted @ 2020-11-01 18:04 WP-WangPin 阅读(116) 评论(0) 推荐(0) 编辑