JavaScript
文章平均质量分 65
JavaScript ( JS ) 是一种具有函数优先的轻量级,解释型或即时编译型的编程语言。虽然它是作为开发Web 页面的脚本语言而出名的,但是它也被用到了很多非浏览器环境中
恒宝乐园
好好工作,好好生活。
展开
-
webpack 用 webpack-parallel-uglify-plugin 打包报错 warnings is not a supported option
warningsis not a supported option 意思是:不支持“警告”选项。我们需要修改配置。转载 2024-05-30 17:12:51 · 89 阅读 · 0 评论 -
学习ECMAScript 2015 系列文章已更完
本文为ECMA Script2015系列文章的目录文章原创 2021-12-28 20:17:16 · 313 阅读 · 0 评论 -
Bootstrap-fileinput-master脚本正确却显示不出正确结果
运行环境:xp系统、谷歌浏览器 跟着demo学着使用这个控件,老老实实在head里写了$("#file-1").fileinput({ uploadUrl: '#', // you must set a valid URL here else you will get an error allowedFileExtensions :原创 2016-10-14 08:25:54 · 3060 阅读 · 2 评论 -
学习ECMAScript 2015【19】Tail Calls
https://babeljs.io/docs/en/learn#tail-calls原创 2021-11-25 08:00:00 · 339 阅读 · 0 评论 -
学习ECMAScript 2015【18】Reflect API
https://babeljs.io/docs/en/learn#reflect-api原创 2021-11-24 07:15:00 · 186 阅读 · 0 评论 -
学习ECMAScript 2015【17】Promises
https://babeljs.io/docs/en/learn#promises原创 2021-11-23 08:30:00 · 420 阅读 · 0 评论 -
学习ECMAScript 2015【16】Binary and Octal Literals
https://babeljs.io/docs/en/learn#binary-and-octal-literals原创 2021-11-22 08:45:00 · 221 阅读 · 0 评论 -
学习ECMAScript 2015【15】Math + Number + String + Object APIs
https://babeljs.io/docs/en/learn#math–number–string–object-apis原创 2021-11-21 09:00:00 · 338 阅读 · 0 评论 -
学习ECMAScript 2015【14】Symbols
https://babeljs.io/docs/en/learn#symbols原创 2021-11-20 10:52:57 · 4171 阅读 · 0 评论 -
学习ECMAScript 2015【13】Proxies
0.背景原创 2021-11-19 09:00:00 · 536 阅读 · 0 评论 -
学习ECMAScript 2015【12】Map + Set + WeakMap + WeakSet
0. 简介今天的主角是 WeakMap + WeakSet,没啥可说的,都是一些数据结构的基本操作。最近天气冷了,提醒大家注意保暖。1.总览在使用中,一般这样使用:// Setsvar s = new Set();s.add("hello").add("goodbye").add("hello");s.size === 2;s.has("hello") === true;// Mapsvar m = new Map();m.set("hello", 42);m.set(s, 34原创 2021-11-18 00:00:00 · 364 阅读 · 0 评论 -
学习ECMAScript 2015【6】Default + Rest + Spread
0.前言今天所要讨论的是:Default + Rest + Spread,看着有点糊涂,其实说全了,就是:default parameters, rest parameters and the spread operator.1.总览function f(x, y=12) { // y is 12 if not passed (or passed as undefined) return x + y;}f(3) == 15function f(x, ...y) { // y is原创 2021-11-10 12:00:00 · 176 阅读 · 0 评论 -
Postman使用JS脚本实现请求时加密
0.背景 当我们在请求后端接口时,正常情况下,都是明文,较为安全的方式是通过https。但是在一些特定的步骤,比如登录,需要对请求参数进行加密。1.如何在请求完成后,执行脚本 我们需要在Postman的Tests一栏中写入脚本。 这个时候你就会问了,如果我这里的结果,另一个请求的时候要用到怎么办?那你就可以创建一个环境变量,然后赋值给它,创建环境变量在右上角的小眼睛按钮那里。 在脚本里赋值的时候,右侧有示例的代码,基本上是下面这样的过程:pm.test("Your test name原创 2021-11-02 12:00:47 · 11085 阅读 · 1 评论 -
JS:null在if语句中是false
这几天看开源项目的大神们写的JS代码中,常常看到这样的句子:let obj = ......if(obj){ ...}头一次看的时候,我是直到,我看到了下面这段话:“null is a falsy value (i.e. it evaluates to false if coerced to a boolean)” — Josh Clanton at A Drip of JavaScript当然了,更多的,要看:How to Check for null in JavaScript原创 2021-11-03 04:30:00 · 416 阅读 · 0 评论 -
学习ECMAScript 2015【10】Unicode
0.背景本文的主角是 Unicode ,没啥可说的,水一篇吧。1.Unicode// same as ES5.1"????".length == 2// new RegExp behaviour, opt-in ‘u’"????".match(/./u)[0].length == 2// new form"\u{20BB7}" == "????""????" == "\uD842\uDFB7"// new String ops"????".codePointAt(0) == 0x原创 2021-11-14 18:00:00 · 415 阅读 · 0 评论 -
学习ECMAScript 2015【9】Generators
0.背景今天要讨论的Generators,在上一篇中提到过,这一篇稍微谈谈。1.概览生成器的写法var fibonacci = { [Symbol.iterator]: function*() { var pre = 0, cur = 1; for (;;) { var temp = pre; pre = cur; cur += temp; yield cur; } }}for (var n of fibonac原创 2021-11-13 13:00:00 · 269 阅读 · 0 评论 -
学习ECMAScript 2015【8】Iterators + For..Of
0.背景今天要介绍的Iterators + For…Of和Java中的增强for循环很类似。可以用在能够迭代的对象上。你也许会问:“不是有for in了吗?”别急,后面说。1.总览let fibonacci = { [Symbol.iterator]() { let pre = 0, cur = 1; return { next() { [pre, cur] = [cur, pre + cur]; return { done: fals原创 2021-11-12 08:30:00 · 331 阅读 · 0 评论 -
学习ECMAScript 2015【7】Let + Const
0.前言今天的主角是:Let + Const,其实就是防止var乱跑而设计的。写过老的js代码的都或多或少经历过重名的变量带来的困扰。1.总览一言以蔽之,let就是打大括号内的var,const就是常量。function f() { { let x; { // this is ok since it's a block scoped name const x = "sneaky"; // error, was just defined with原创 2021-11-11 00:00:00 · 341 阅读 · 0 评论 -
学习ECMAScript 2015【5】Destructuring
0. 引言当我们构建一个对象时,我们如同搭积木一样,拼接不同的部分到一起。当我们解构它时,我们从中抽取一块或多块积木。1.总览下面我们从多个角度去总览其特性,下面列举出了在列表中、对象中的解构方式,方便我们从其中迅速获得我们所需的值。// list matchingvar [a, ,b] = [1,2,3];a === 1;b === 3;// object matchingvar { op: a, lhs: { op: b }, rhs: c } = getASTN原创 2021-11-09 08:50:18 · 162 阅读 · 0 评论 -
学习ECMAScript 2015【4】Template Strings
0. 前言其实这部分特性,在使用axios.get拼接url的时候体现的最明显,经常用到${param}。今天的内容不复杂,轻松愉悦。1.概览好,我们先通过一个简单的例子说明一下:// Basic literal string creation`This is a pretty little template string.`// Multiline strings`In ES5 this is not legal.`// Interpolate variable bindingsv原创 2021-11-07 03:45:00 · 200 阅读 · 0 评论 -
学习ECMAScript 2015【3】Enhanced Object Literals
0. 讲在前面对象字面量扩展语法,其实更多的是书写的便捷。1.总览示例var obj = { // Sets the prototype. "__proto__" or '__proto__' would also work. __proto__: theProtoObj, // Computed property name does not set prototype or trigger early error for // duplicate __proto__原创 2021-11-06 00:30:00 · 282 阅读 · 0 评论 -
学习ECMAScript 2015【2】Classes
0. 前言其实类这个概念,最早在C++出现,Java发扬光大。JS之前也写类,根据文章:JavaScript 定义类的最佳写法——完整支持面向对象(封装、继承、多态),兼容所有浏览器,支持用JSDuck生成文档中的示例,之前的基本长这样:function PersonInfo() { // 自身的实例字段. this.name = ""; // 姓名. this.gender = 0; // 性别. 0未知, 1男, 2女.}那出现单独的关键字好不好呢?当然好了原创 2021-11-05 23:00:00 · 163 阅读 · 0 评论 -
学习ECMAScript 2015【1】Arrows and Lexical This
0.讲在前面 从这篇开始,我开始讲解BABEL官网提供的Learn ES2015文章,由于原文较长,我每一节整理成一篇文章。有感兴趣的小伙伴,一定要去原文看看。1.ECMAScript 2015ECMAScript 2015 is an ECMAScript standard that was ratified in June 2015. 就像上面这句话说得那样,2015年6月份批准的标准。什么标准呢?ECMAScript 2015 !啥是ECMAScript?ECMAScript是一种由E原创 2021-11-04 05:30:00 · 308 阅读 · 0 评论 -
学习ECMAScript 2015【11】Modules
0.背景 本文的主角是 Modules 。你会问:“必须模块化吗?可是经理让我一分钟后上线!”1.总览 其实写Vue项目的时候,很多时候都用到了模块化编程,常常写export import,好,我们先简要浏览一下:// lib/math.jsexport function sum(x, y) { return x + y;}export var pi = 3.141593;// app.jsimport * as math from "lib/math";console.lo原创 2021-11-15 15:15:00 · 481 阅读 · 0 评论