自己编译个模板 以前自己也写过编译模板的东西,但是时间长就忘记了。。。今天看到了相关的东西,就又动手写了写。const supplies = ['a', 'b'];const wm=123;let template = ` <%= wm %> <!--注释--><ul> <% for(let i=0; i < supplies.length; i...
前端性能优化 —— 前端性能分析 还有这种操作function performanceTest() { let timing = performance.timing, readyStart = timing.fetchStart - timing.navigationStart, redirectTime = timing.redirectEnd - timing.redirectStart,
鼠标掠过iframe事件mousemove 在父页面中绑定了mousemove,但是鼠标经过iframe的时候却没有触发事件,只要加上一点css就好了iframe { pointer-events:none; }
react使用useContext实现兄弟组件通信 两个兄弟input通信,实现输入同步无useReducer版本<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <title>Title</title> <script src="https://unpkg.com/react@16/umd/react.development.js" crossorigin></sc
取消fetch请求 const controller = new AbortController();const signal = controller.signal;// API responds after 5s// Note the 'signal' in the second argumentfetch('https://slowmo.glitch.me/5000', { signal }) .then(r => r.json()) .then(response => console.lo
尺寸大小不固定图片在一个不固定大小的容器中保持原比例水平垂直居中 请注意,是图片居中,不是img标签居中,<style> *{ padding:0; margin:0; } body{ width:100%; height: 100vh; } img{ background: red; width:100%; he
try catch promise.reject 突发奇想,测试了下面的一段代码,function f() { try{ Promise.reject('我错了'); }catch(e){ console.log('e',e); }}f();结果没有catch,我就不明白了,到底为什么。难道Promise.reject是异步?我问别人,有人告诉我是因为异步,但是我认为不是...
svelte与CustomEvent 在svelte中下级给上级发射事件一般是这种形式: import { createEventDispatcher } from "svelte"; const dispatch = createEventDispatcher(); dispatch("myevent", { });而 createEventDispatcher 的源码中使用了一个自定义函数custom_event...
多出文字显示点点点-webkit-line-clamp 以前以为文字多了显示点点点只能用WTO,但是WTO处理多行不方便,今天学到一个新的:-webkit-line-clamp <style> p { width: 300px; display: -webkit-box; -webkit-box-orient: vertical; ...
希望nginx不发生301在url后面加斜杠 浏览器访问一个页面,http://abc.com/fanglu-h5,nginx这么配置:server { listen 80; server_name abc.com; location /fanglu-h5 { root /home/ctivity/; index index.html; }}发生301.如下图所示:不想让他这样...
node.js接收前端上传的文件 打算前端传文件给后端node,前端使用formdata,尝试使用koa的multer包来做,但是老是报错, MulterError: Unexpected field在网上找了半天,不知道怎么直接用node(不用框架和第三方包)从request中解析出来文件,所以自己想了个方法变换一下来做,很简单,特此记录。「Talk is cheap. Show me the code」0 前端代码...
angular依赖注入providedIn与懒加载的问题循环依赖 1. providedIn: ‘root’The @Injectable() decorator has the providedIn metadata option, where you can specify the provider of the decorated service class with the root injector, or with the injector for...
javascript中的同步迭代和异步迭代 所谓的迭代,用过es6的兄弟肯定已经接触过了,比如arr是一个数组,**[…arr]**还有for of 循环都是的。我说一说他背后的东西。同步迭代The interfaces for sync iteration ,借助typescript来写:interface Iterable { [Symbol.iterator]() : Iterator;}interface Iter...
使用node杀死linux进程及子进程们 用linux 写了打包脚本,想要杀死正在跑着的打包程序,但是直接用linux的命令就是杀不死,无奈只能改成node试一试,#! /home/broly/.nvm/versions/node/v10.15.1/bin/nodelet {exec} = require('child_process');let {promisify} = require('util');let exec2 = ...
javascript深度广度遍历DOM及二叉树以及求深度 console.log('深度'); function d(e) { console.log(e); const ren = e.children; // 如果是二叉树,则 // const ren =[e.left,e.right].filter(ei=>!!ei); if (ren.length) { Array.from(ren...
Generator + Promise实现async+await的效果 很久以前用koajs 1的时候也看过co库的核心源码,后来不用了,前段时间又涉及到了相关的问题,特地重新学习一下, koajs 1 中如何实现的async await的效果。首先,2个基本知识:Promise.resolve flattens nested layers of promise-like objects (e.g. a promise that resolves to a pr...
angular中组件changeDetection为ChangeDetectionStrategy.OnPush时的学习 一个angular应用是由组件树组成的,changeDetection是其中比较深的部分,我也不懂哈。angular中changeDetection中的策略有这样的描述:总而言之,对于一个组件而言,2中changeDetection策略,默认的没啥好说的,主要说一下OnPush的情况。如果子组件的属性的变化由输入属性决定,那么这个时候就可以启用OnPush这种变更检测策略,这样输入属性不变的...
angular中的RouteReuseStrategy的学习小记 惭愧,看了别人用vue写出了返回不需要刷新的效果才想到在angular中实现,才有了这次的学习。就是想要返回不刷新1. angular中RouteReuseStrategy是这样的:abstract class RouteReuseStrategy { abstract shouldDetach(route: ActivatedRouteSnapshot): boolean abst...
javascript和dart中for循环里面异步任务promise和future 最新看dart,对比学习吧。。。要实现的效果,根据一个数组,生成一个定时器,定时器n秒之后返回,串行执行。javascript版本:function getPromise({ milliseconds = 0 } = {}) { return new Promise((resolve) => { setTimeout(() => { ...
javascript和dart中函数传参数的小对比:位置参数和命名参数 1、 default values for positional parameters1.1、js版本function positional(a,b=9){ console.log('a:',a); console.log('b:',b);}console.log(`一个实参:`);positional(5);console.log(`二个实参:`);positional(...
部署sentry的过程中遇到的一些问题记录:企业微信邮件、soucemap等 0. 系统环境与安装[root@xxxxxxxxx]# uname -aLinux iz2ze7ki6m0w5zsxd5kc4jz 3.10.0-862.6.3.el7.x86_64 #1 SMP Tue Jun 26 16:32:21 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux[root@xxxxxxxxx]# lsb_release -aLSB Ve...
flex和grid中容器的伪元素::before和::after生成的内容被视为一个子元素项目 一个以前不知道的知识点<style> .grid { display: grid; grid-template-columns: 1fr 1fr 1fr 1fr; grid-template-rows: 100px 100px; grid-gap: 20px; } .flex { ...
nodemailer发邮件给腾讯企业邮箱的时候填写密码 这个密码啊,用我自己的腾讯企业邮箱的密码发送不行,可以这么搞定:邮箱设置----微信绑定----安全登录-----客户端专用密码生成一个新的就行了
Require Function Parameters 和 Get Query String Parameters Require Function ParametersBeing able to set default values for function arguments was an awesome addition to JavaScript, but check out this trick for requiring values be passed for a given argument:...
Fading out siblings on hover in CSS 原文连接:https://www.trysmudford.com/blog/fade-out-siblings-css-trick/要实现下面这样的效果:通常,会把hover事件加在card1,card2,card3上,但是通过加在父元素上也可以实现。初始代码如下: <style> .parent { display: flex; heigh...
javascript中Rest/Spread与Object.assign的不同 ES6中的Rest/Spread使用的很广泛了,比如简单的(浅)复制一个数组:const arr1 = [10, 20, 30];// 复制一下const copy = [...arr1];console.log(copy); // [10, 20, 30]再比如给一个函数传递参数,参数需要一个个地传递,现在参数都在一个数组里面:const arr = [10, 20,...
简单学习rxjs中map、concatAll、concatMap、mergeAll、mergeMap、switchAll、switchMap 1、mapmap和javascript中的数组的map方法类似,不过这里为了结合下面的demo,我先用map做一个我们不想要的效果: const getData = (param) => { return of(`return: ${param}`).pipe( delay(Math.random() * 1000) ) }; from([1, ...
rxjs中的throttle、throttleTime、debounce、debounceTime、audit、audtiTime 1、debounceTimeEmits a value from the source Observable only after a particular time span has passed without another source emission.大意是,只有在指定的时间间隔内没有产生另外的数据的时候,之前产生的数据才能被observable发射出来。marble diag...
学习CSSOM 通过element.style访问或者设置行内样式 div { width: 100px; height: 100px; background-color: rgb(255, 255, 0); } // 下面是div的结构 &amp;amp;amp;lt;div&amp;amp;amp;gt; 我是div里面的内容哦&amp;amp;amp;lt;/div&amp;amp;amp;
angular开发项目文件系统打开后base路径和background图片路径找不到的问题 1、删掉base标签,也不要动态写入2、背景图片改成相对路径,我发现这样会直接编译成base64格式的 background: url(…/…/…/assets/apply_cash_bg.png)
nginx rewrite导致post问题 问题背景开始的时候前端用的3000端口发的post请求到node,node做了检测要求必须用post,不能用get,这个时候前端请求的接口是xxxx:3000/servers, 但是前端是用nginx部署在81端口的,这导致请求老是发2次,看起来不好看。尝试解决把前端请求的接口改成xxxx:81/api/servers ,用nginx做一次转发,开始是这么写的nginx的配置: locat...
mongo 4 中事务的简单学习 我也的mongo的版本是4.0.4这是一个新增的功能,以前不支持事务1. run-rs与replica set事务操作如果连接的mongo不是副本集的话,会报错:Transaction numbers are only allowed on a replica set member or mongos所以还要想办法弄个副本集出来,为了方便,使用了run-rs这个npm包,开启副本集...
mongodb设置用户名和密码并用node连接 我用的mongo的版本是4.0.41、设置用户名和密码1.1 设置admin库的用户名密码> show dbsadmin 0.000GBconfig 0.000GBlocal 0.000GBxxxx 0.000GB> use adminswitched to db admin> db.createUser({ user: "admin", pw...
魔法CSS(1)——消失的list-style 来源:https://segmentfault.com/a/1190000016969667?utm_medium=hao.caibaojian.com&utm_source=hao.caibaojian.com&share_user=1030000000178452<ul> <li> <p>啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊...
学习CSS Scroll Snapping与scroll-snap-align 假如有个Web页面是一块一块的,如下图所示:我们希望可以一块一块的滚动,比如当前一个块滚出去了一部分并且后一个块滚进来一部分的时候,实现后一个块自动滚入或者前一个块回弹到初始位置这种效果,以前的时候用js需要写比较复杂的判断逻辑,后来有了一个css scroll snap这个方法,可以比较方便的实现想要的效果了,基本够用。基本页面css代码:ul { max-height: ...
自定义html5中的details元素 html5中的details的功能很好,但是默认的样式不好看…尝试修改。::-webkit-details-marker伪元素修改 summary前面的三角形summary的::before和::after伪类制作一个 + - 表示的开关使用details的open属性选择器在开关之间进行却换下面是样式文件: ::-webkit-details-marker { ...
html的dialog标签元素 以前的时候为了在页面上做出dialog效果往往很复杂,还要写遮罩层,用CSS 写 好多代码,不过刚刚知道html中原生也支持dialog。标准用法 <dialog open> <h1>你好</h1> </dialog>可以通过改变open属性,来显示或者隐藏,如上图所示。也可以使用dialog的show方法或者close方法...
win10通过samba实现在主机中开发虚拟机中编译 因为我是进行前端开发的,所谓的编译是指的是编译angular项目公司的平台基于angular搭建了前端开发环境,开发的时候要开启一个类似angular中ng start的命令,所有的一切麻烦都是这个命令引起的。公司开发的不支持windows系统,而我使用的是win10,不想换mac,于是我就开始了折腾。。。尝试1:使用win10的linux子系统wsl那好啊,反正win10里面可以使用...
pngquant failed to build, make sure that libpng-dev is installed sudo apt-get install libpng-dev npm install -g pngquant-bin 如果还不行,再加上: sudo apt-get install -y build-essential libpng-dev
angular使用class-interface获取父组件和祖先组件 在angular中,并没有现成的方法获取父组件,但是: because every component instance is added to an injector’s container, you can use Angular dependency injection to reach a parent component. 那么,如果父组件能在依赖注入中把自己当作一个服务注入,后代就能...
angular动态组件与内容投影二 不是我的原创,也不是不是我的原创,是在理解原文的基础上修改而来的,还对某些api进行了升级可以使用容器的createComponent方法来创建组件,但是这个方法还可以有甚多别的参数,比如传递服务参数和内容投影参数,这次就学习下。如我们有一个组件AdvComponent,希望当鼠标放上的时候动态创建一个组件TooltipComponent,TooltipComponent中还包括一个内容投...
angular中动态创建组件(一) 最近做东西用到了大量动态组件相关的知识,先总结一下一种比较简单的。已经有了一个组件,AppComponent,也有一个将要动态创建的组件MsgComponent,@Component({ selector: 'msg', template: ` &amp;lt;h3&amp;gt;{{type}}&amp;lt;/h3&amp;gt; `})export class MsgComponent ...
angular中服务b依赖服务a如何export 1.服务b依赖与服务a的一般情况一个模块中的一个一个组件,AbComponent,其中需要注入服务BService。import {Component} from '@angular/core';import {BService} from './b.service';@Component({ template: ''})export class AbComponent {...
angular中使用viewchild访问DOM、子组件和指令的学习 angular中的viewchild提供了访问从组件中访问模板中书写的DOM、子组件和指令的功能。0. 基础知识ViewChild Property decorator that configures a view query. The change detector looks for the first element or the directive matching...
angular input binding 输入型绑定 Content Projection 内容投影 通过输入型绑定可以把把数据从父组件传到子组件。官网的demo比较简单,我试的时候发现父组件不仅可以传递一个普通的属性给子组件,还可以是函数的运行结果,而且这个函数的结果还是不断的变化的。好神奇。在这里设计2个组件,父组件中在input框中输入值,传递给子组件,同时还传递一个对象和一个函数的运行结果。父组件的主要代码:parentSimple = '123';parentObject ...
angular属性绑定绑定函数,插值表达式插函数,ngIf绑定函数 以前认为angular属性绑定的时候只能绑定属性,官网上也没说能绑定函数,看同事代码的时候被惊呆了,可以绑定函数,而不仅仅是属性,可以绑定函数,而不仅仅是属性,可以绑定函数,而不仅仅是属性,整理一下相关的用法。没想到angular里面还可以这样。import {Component} from '@angular/core';@Component({ templateUrl: './fun...
clip-path的学习和简单使用 遇到一个情况,图片太长需要截短一些,开始用了clip,后来发现这个属性已经从CSS标准里面删除了,然后看到了clip-path,发现这个比较强大一些。 我用的图片的大小是600*774clip-path裁剪出圆形 clip-path:circle(40% at 200px 200px);效果如下: 40%是半径,at后面的参数是圆心。clip-path 裁...
Element dimensions offset dimensionsall of the visual space that an element takes up on the screen. including all padding, scrollbars , and borders ( but not including margins ). client dimensionsthe space occ...
angular中的HostBinding与HostListener 水平浅,各位看官不要见怪 In Angular, the @HostBinding() function decorator allows you to set the properties of the host element from the directive class. In Angular, the @HostListener() function decorator...
记录使用es6模块的一次错误以及与commonjs规范中模块的区别 先看commonjs规范中的代码: a102.js中代码:function fun(){ console.log('fun');}// export {fun}setTimeout(fun,1000)exports.fun=fun;a101.js中代码:let fun=require('./a102').fun;fun=function(){ console.l...
HTML attribute vs. DOM property The distinction between an HTML attribute and a DOM property is crucial to understanding how Angular binding works.Attributes are defined by HTML. Properties are defined by the DOM (Document Object ...
Professional JS for Web Developers (third edition) 随手笔记(1)前4章 2 JavaScript in HTMLdeferred scriptsthe purpose of defer is to indicate that a script won’t be changing the structure of the page as it executes. Setting the defer attribute on a Asynchronous ...
Channel Messaging与structured clone 才疏学浅,以前没听过structured clone(结构化克隆)这个词语,最近才看到。Channel Messaging API ,允许附着在同一个文档上的两个运行在不同上下文的脚本直接通信。window下的postMessagepostMessage这个东西以前也用过,比如下面这个demo所示的用法:我用的webstormindex.html嵌套一个iframe,在inde...
学习service worker之一:两种更新 下面把学习的过程中遇到的问题和感悟记录如下: 我用的webstorm一个页面,引入了index.js,index.js的代码如下:navigator.serviceWorker .register('./sw.js') .then(function (reg) { console.log('Service Worker Registered')...
popstate 今天测试一个h5中的popstate事件,虽然我很久之前就对这个新属性有所学习, https://blog.csdn.net/zgrbsbf/article/details/25297359 无奈今天还是犯了几个小错误,记录如下:错误:https://developer.mozilla.org/en-US/docs/Web/Events/popstate 这篇文章中说, ...
chrome 66 让事件侦听器的断点更好用 使用的是angular 5开发的时候如果使用了一个js库或者前端框架,调试的时候想添加事件监听,但是断点会停在这些库或者框架里面,不是我们想要的效果,比如下面的例子: ‘添加’按钮上面绑定了一个click事件, 先设置click的断点,然后点击”添加”,停下了,如下图2: 但是停在了angular的框架里面,我想让他暂停在我写代码的地方,怎么做到呢: 在图1的右侧的箭头...
Destructuring解构javascript与python python版的:a, (b, [c, d]) = (1, [2, iter((3, 4))])print(a, b, c, d)head, *tail=(1,2,3)print(head,tail)js版的:let [a, [b, [c, d]]] = [1, [2, [3, 4]]];console.log(a, b, c, d);let [head, ......
深入浅出node.js第9章玩转进程摘录 9.1 服务模型的变迁9.1.1 石器时代:同步9.1.2 青铜时代:复制进程9.1.3 白银时代:多线程9.1.4 黄金时代:事件驱动9.2 多进程架构node提供了child_process模块,我们再将经典的示例代码存为worker.js文件,如下:let http=require('http');http.createServer(fu...
node.js私有连智能合约开发学习1 使用的win101、安装geth1.1 启动一个私有链geth --rpc --rpcport "8545" --rpcapi "eth,web3,personal,net" --rpccorsdomain * console 2>>test.log --dev如下图所示: 参数解析:–rpc:激活节点上的RPC–rpcapi:配置什么...
win10 小娜cortana搜索网页使用自定义浏览器 看下面: https://www.makeuseof.com/tag/force-cortana-use-chrome-google-windows-10/
Fatal: Unable to attach to remote geth: no known transport for URL scheme "c" 我的系统是win10,geth的版本是 1.8.2-stable-b8b9f7f4按照http://www.cnblogs.com/huyouhengbc/p/5922093.html 的示例,尝试写智能合约的时候,C:\Users\myname>geth attachFatal: Unable to attach to remote geth: no known transpo...
深入浅出node.js第4章异步编程摘录 4.1函数式编程4.2异步编程的优势与难点4.2.1 优势node带来的最大特性莫过于基于事件驱动的非阻塞I/O模型,这是他的灵魂所在。 在第3章中,我们讨论过node实现异步I/O的原理。利用事件循环的方式,js线程就像一个分配任务和处理结果的大管家,io线程池里的各个io线程都是小二,负责完成分配来的任务,小二与管家互不依赖,所以可以保持整体的高效率。缺点是管家无法承担过...
深入浅出node第3章异步I/O摘录 3 异步I/O3.1 为什么要异步I/O3.1.1 用户体验//消费时间为mgetData('from_db')//消费时间为ngetData('from_remote_api')getData('from_db',function(re){//消费时间m});getData('from_remote_api',function(re){//消费时间n...
https建立安全连接,tls握手协商过程的疑问 查看了很多讲解https的东西,最后总结如下:The client sends a “Client hello” message to the server, along with the client’s random value(RAlice) and supported cipher suites.该过程为明文。The server responds by sending a “...
学习koa koa的版本是2.5.0源demo来自http://koajs.com 第一次写这种东西,最起码让我自己看懂吧!最原始的简单的node的http服务器就像下面这样: var http = require('http');//create a server object:http.createServer(function (req, res) { res.wr...
pm2开机重启node程序 上次linux服务器宕机,node程序没重启,看到网上说啥的都有,亲自测试了一下: node的版本是9.6.1,pm2的版本是2.10.1首先启动node程序 然后pm2 save,输出类似下面的东西[PM2] Saving current process list...[PM2] Successfully saved in /root/.pm2/dump.pm2最后pm2 ...
yum update错误Couldn't resolve host Loaded plugins: fastestmirror, securitySetting up Update ProcessDetermining fastest mirrorshttp://xxx.com:8050/Centos/6/base/x86_64/repodata/repomd.xml: [Errno 14] PYCURL ERROR 6 - "Couldn't resolv...
nginx中rewrite常用全局变量 摘抄自nginx高性能web服务器详解 变量 说明 $args 存放了请求url中的请求指令。比如http://www.myweb.name/server/source?arg1=value1&arg2=value2中的arg1=value1&arg2=value2 $content_length 存放请求头中的Content-length...
第三方app微信登录 Created with Raphaël 2.1.2人人超级游戏超级游戏微信微信代理层代理层登录请求授权,scope,state...确认?确认吊起,code请求人的信息,带code请求access_token(code,appid,secert,grant_type=authorization_code)返回access_token,openid请求人的信息(access_token,openi
node访问某个ip下的某个server 看前人的项目,实现的是一个访问某个ip的某个server的功能,他们用了privoxy和node来实现的,如果纯用node的话,可以使用http.request方法,这样就不用安装别的东西了。下面的这个就是访问127.0.0.1上的abc.com的一个demo。let querystring=require('querystring')let http=require('http');
javascript中的marotask与microtask与事件循环 setTimeout(function(){ console.log('定时器开始啦') });new Promise(function(resolve){ console.log('马上执行for循环啦'); for(var i = 0; i &amp;lt; 10000; i++){ i == 99&amp;amp;&amp;amp; resolve(); ...
positive definite matrix positive definite matrixA positive definite matrix is a symmetric matrix with all positive eigenvalues. Note that as it’s a symmetric matrix all the eigenvalues are real, so it makes sense to talk a
rsync的@ERROR: Unknown module xxx 错误 搞了好几个小时@ERROR: Unknown module 'xxx'rsync error: error starting client-server protocol (code 5) at main.c(1503) [sender=3.0.6]原因如下:rsyncd.conf中的对应项目的hosts allow属性写错了,那你也应该提示host被禁止啊,为什么提示unkno
javascript与python的生成器(Generators)实例 斐波那契数列先来js版的function* fibon(n) { let a = b = 1; for(let i=1;i<= n;i++) { yield a; [a, b] = [b, a + b]; }}for(let v of fibon(10)){ console.log(v);}再来py版的def fibon(n): a = b = 1
javascript与python的rest 参数实例 先来js版的不定参数function test_var_args(f_arg,...argv) { console.log('first normal arg:',f_arg); for(let arg of argv){ console.log("another arg through *argv:", arg); }}test_var_args('yasoob', 'py
named capture groups const pattern = /(?\d{4})-(?\d{2})-(?\d{2})/u;const result = pattern.exec('2017-12-15');// result.groups.year === '2017'// result.groups.month === '12'// result.groups.day === '15'参考文献:https
安装nginx同时安装redis2-nginx-module模块 安装rediswget http://download.redis.io/releases/redis-3.2.9.tar.gztar xzf redis-3.2.9.tar.gzcd redis-3.2.9make下载nginx及其redis模块wget -c https://nginx.org/download/nginx-1.10.1.tar.gz 接下...
判断横竖屏的一个小方法 var mql = window.matchMedia("(orientation: portrait)");function onMatchMeidaChange(mql){ if(mql.matches) { // 竖屏 }else { // 横屏 }}onMatchMeidaChange(mql);mql.ad
// Error: MISCONF Redis is configured to save RDB snapshots, but is currently not able to persist on // Error: MISCONF Redis is configured to save RDB snapshots, but is currently not able to persist on disk. Commands that may modify the data set are disabled. Please check Redis logs for details about
mongodb的aggregate实例1 好不容易写的,得记录一下,免得找不到了[ { $match: { "from": 'h5player', 'code': {$in: ['init']} } }, { $group: { "_id": { code: '$code', 'cost': { $switch:
迁移mongodb数据库 版本3.0.6 因为a服务器要关闭了,但是上面有个mongodb,要把他迁移到b服务器上。两个机器上的moongodb版本都是3.0.6假设a的ip和端口是是a.a.a.a:a ,要迁移的a的数据库中的一个是jscss在b服务器上执行下面的命令1、./mongodump -h a.a.a.a:a -d jscss -o /abc/bak 这句话就把a上面的jscss数据库备份到了b的/
closures and variables There is one notable side effect of this scope-chain configuration. The closure always gets the last value of any variable from the containing function.Remember that the closure stores a reference to
closures Closures are functions that have access to variables from another function's scope. This is often accomplished by creating a function inside a function:function createComparisonFunction(propertyName
execution context and scope The concept of execution context, referred to as context for simplicity, is of the utmost importance in JavaScript. The execution context of a variable or function defines what other data it has acces
the constructor pattern function sayName(){alert(this.name);}function Person(name,age){this.name=name;this.age=age;this.sayName=sayName;}var person1=new Person('nic',29);To create a new instance of Pers
内部使用的解析require RegExp.escape = function (s) {return s.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');};let hh=['','-','=','+',"{",'[','(','*',"~","/","%",">","var fs = require('fs');var file = './code.js';var
chrome64的Local Overrides 这个功能就是为了对付在开发者工具中修改了东西后一刷新什么都没了的尴尬,这么操作:以调试youku的代码为例:在开发者工具中打开下面的面板:sources-->overrides-->setup overrides选择完了本地的存放目录后还需要把下面的这个勾选上才能起作用选择一个一个文件,然后修改一下,之后得按下ctrl+s
chrome64滚动链及overscroll-behavior overscroll-behavior的三个属性:auto:默认的情况contain:阻止滚动链none:和上一个一样,并且能阻止浏览器过渡滚动导致的Android 炫光或 iOS 回弹(Android overscroll glow or iOS rubberbanding)另外,js判断浏览器是否支持某个css属性,CSS.supports正在滚动的元素:doc
chrome64新增的Performance Monitor chrome64中新增了一个可以多角度实时查看页面性能的开发者工具,可以这么打开:用它检测一下国内的这几个主流的视频网站的首页cpu usage的数据都是变来变去的,估计是因为各家都有大量的定时器吧。DOM 结点的数量爱奇艺的最少,但是他的JS heap size并不是按照比例最小的。以前以为爱奇艺是性能最好的,现在一看也未必啊
element traversal childElementCount: returns the number of child elements (excludes text nodes and comments);firstElementChild: points to the first child that is an element.Element-only version of firstChildlastEl
javascript从jQuery中借鉴的DOM操作 用$e表示jQuery选中的元素,e表示原生js选中的元素1、在元素js中,删除一个元素往往这么干:e.parentNode.removeChild(e);就是得绕一圈,从父元素中将其删除,在JQuery中,可以直接这样:$e.remove(); 后来原生js引入了这个方法,直接这么干了:e.remove()2、insert as the new fir
Reading Property Attributes It's also possible to retrieve the property descriptor for a given property by using the ES5 Object.getOwnPropertyDescriptor() method.This method accepts two arguments:the object on which the property
Types of Properties--Accessor Properties Accessor properties do not contain a data value.Instead ,they contain a combination of a getter function and a setter function(thought both are not necessary).When an accessor property is read from,th
Types of Properties--Data Properties ECMA-262 fifth edition describes characteristics of properties through the use of internal-only attributes.These attributes are defined by the specification for implementation in JavaScript engines, a
javascript中的原型与继承6--class的继承 先来一个老的继承function SuperType(name) {}function SubType(name,age) {}SubType.prototype=Object.create(SuperType.prototype);console.log(SuperType.prototype.__proto__==Object.prototype
javascript中的原型与继承5--寄生混合继承(Parasitic Combination Inheritance) 接着这篇 http://blog.csdn.net/zgrbsbf/article/details/78643523混合继承优缺点,就是SuperType的构造函数调用了两次。解决之。第二次的调用不可避免,我们从第一次入手。SubType.prototype=new SuperType();将它替换成SubType.prototype=Object.create(
javascript中的原型与继承3-混合继承(Combination Inheritance) 混合继承,又叫做伪古典继承(pseudoclassical inheritance),他就是把原型链和构造函数窃取结合在了一起,使用原型链继承属性和方法,使用构造函数窃取来得到实例属性。//例子来源于Professional JavaScript for Web Developers,third edition ,Volume 1的209页function SuperType(name)
javascript中的原型与继承4--原型继承Prototypal Inheritance(Object.create)与寄生继承(Parasitic Inheritance) 在2006年的时候,一个叫做Douglas Crockford的哥们发明了一个新的继承方式,这种方式不需要定义构造函数。他是这么做的//210页function object(o) {function F() {}F.prototype=o;return new F();}//essentially,object() performs a shadow copy of