Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

知识点 #11

Open
lifeiFront opened this issue May 15, 2018 · 0 comments
Open

知识点 #11

lifeiFront opened this issue May 15, 2018 · 0 comments

Comments

@lifeiFront
Copy link
Owner

lifeiFront commented May 15, 2018

  1. HTTPS下加载HTTP协议的JS、CSS、iframe、字体资源都会被浏览器blocked掉,此时performance.getEntriesByType方法取不到被blocked的资源;HTTPS下加载HTTP协议的图片和视频会有警告,但不会被blocked掉,可以正常加载,其中img资源可以由performance.getEntriesByType方法获取,video资源performance.getEntriesByType获取不到

  2. npm依赖是以最外层的package.json版本号为准。比如最外层的package.jsonreact的依赖版本是16.0.0,同时依赖的react-hot-loader所依赖的版本是16.2.0,那么npm install之后,react版本是16.0.0

  3. Node.js中涉及到对文件每行遍历的库如n-readlinesline-reader,在它们提供的读取每一行的回调中,return false表示结束对当前文件的读取。如果我们不是想结束文件读取,只是想跳过此次遍历的话,请使用return

    var lineReader = require('line-reader');
    
    lineReader.eachLine('file.txt', function(line, last) {
      console.log(line);
    
      if (/* done */) {
         return false; // stop reading
      }
    
      if (/* 跳过此次遍历 */) {
        return; // next line
      }
    });
    
  4. pm2 module安装在/root/.pm2/module下,是全版本共享的。
    5、Math.random()方法返回一个介于0--1之间的随机数,但是不包含0和1(注意:不包含0和1);
    套用下面的公式,可以获得某个整数范围内的随机值:
    值 = Math.floor(Math.random()*可能值的总数+第一个可能得值)

function selectFrom(lowerVal,upperVal) {
    if(typeof lowerVal !== 'number' || typeof upperVal !== 'number'){
        return false;
    }
    return Math.floor(Math.random()*(upperVal-lowerVal+1)+lowerVal);
}
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant