Knowledge Points in Peacetime Work and Study

Posted by webrajesh on Fri, 11 Oct 2019 17:26:44 +0200

13. Use of meta tags

<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<!-- Use the latest browser by default -->
<meta http-equiv="Cache-Control" content="no-siteapp">
<!-- Not being webpage(accelerate)transcoding -->
<meta name="robots" content="index,follow">
<!-- Search Engine Grab -->
<meta name="renderer" content="webkit">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no, minimal-ui">
<meta name="apple-mobile-web-app-capable" content="yes">
<!-- Delete Apple's default toolbar and menu bar -->
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
<!-- Setting Apple Toolbar Colors -->

<meta name="format-detection" content="telephone=no">
<meta name="format-detection" content="date=no">
<meta name="format-detection" content="address=no">
<meta name="format-detection" content="email=no">
<!--Close iOS Content Recognition on-->

http://www.alenqi.site/2018/03/04/complete-tags/
<!--Someone else summed it up meta Links-->

14. randomly generated crypto-random-string

$ npm install crypto-random-string //Installation command

const cryptoRandomString = require('crypto-random-string');
 
cryptoRandomString({length: 10});
//=> '2cf05d94db'
 
cryptoRandomString({length: 10, type: 'base64'});
//=> 'YMiMbaQl6I'
 
cryptoRandomString({length: 10, type: 'url-safe'});
//=> 'YN-tqc8pOw'
 
cryptoRandomString({length: 10, characters: '1234567890'});
//=> '1791935639'

15. Microscopic and Macro Tasks of Browsers

    //The macro task is a task example initiated by the browser host api: setTimeout
    //Micro Task JavaScript Engine Launched Task Example:promise
    //Each macro task has a micro task queue
    //Promises will be added to the end of the macro task
    
    var r = new Promise(function(resolve, reject){
        console.log("a");
        resolve()
    });
    r.then(() => console.log("c"));
    console.log("b")
    //a,b,c

16. lodash Library

  Lodash makes JavaScript easier by making it easier to use array, number, objects, string, and so on. Lodash's modular approach is well suited to:

  Traverse array, object, and string
  Operating and detecting values
  Create functionality-compliant functions
  
  // Load the full build.
  var _ = require('lodash');
  // Load the core build.
  var _ = require('lodash/core');
  // Load the FP build for immutable auto-curried iteratee-first data-last methods.
  var fp = require('lodash/fp');
   
  // Load method categories.
  var array = require('lodash/array');
  var object = require('lodash/fp/object');
   
  // Cherry-pick methods for smaller browserify/rollup/webpack bundles.
  var at = require('lodash/at');
  var curryN = require('lodash/fp/curryN');

17. Small exercises

Title: now we need to achieve a traffic light.
Put a circular div in green for 3 seconds.
Yellow for 1 second and red for 2 seconds to change background color
fuction sleep(duration){
    return new Promise((resove,reject) =>{
        setTimeout(resove,duration)
    })
}
sleep(2000).then(function(){
    
})

18. The Concept of Context

The JavaScript standard puts a piece of code (including functions)
All the information required for execution is defined as "execution context".

19. Local preview function for uploading pictures

  uploadChange(file) {
    console.log(file)
    let blobUrl
    try {
      blobUrl = URL.createObjectURL(file.raw)
    } catch (err) {
      console.error("[Element Error][Upload]", err)
    }
    console.log(blobUrl)
  },
  

URL.createObjectURL() The static method creates a DOMStringļ¼Œ
//It contains a URL that represents the object given in the parameter.
//The life cycle of this URL and the document binding in the window where it was created.
//This new URL object represents the specified File object or Blob object.

//Release memory using the URL. revokeObject URL () method

20. every and some methods

every()Running a given function for each item in an array.
//If the function returns true for each item, it returns true.

some()Running a given function for each item in an array.
//If the function returns true for any item, it returns true.

const tempData = [
  {
    id: 1,
    name: "rocker",
    adress: "US"
  },
  {
    id: 2,
    name: "rocker",
    adress: "US"
  },
  {
    id: 3,
    name: "rocker",
    adress: "US"
  }
];
let everyReturn = tempData.every((item, index) => {
  return item.id > 1;
});
let someReturn = tempData.some((item, index) => {
  return item.id > 2;
});

console.log(everyReturn);
//If one is wrong, return false and the relationship

console.log(someReturn);
//There is a right relationship that returns true or true.

21,npm

View available npm sources
nrm ls

// Usage: nrm use ***
nrm use taobao
 // After switching, you can use nrm ls to see if the npm source has been switched

22. Front End Summary (github Quality Resource Arrangement)

https://juejin.im/post/5d3edad9f265da03a652f133

23. Several Ways of Defining Functions in JavaScript

1. General function
function foo(){
    //code
}
2. Arrow function
const foo = () => {
    //code
}
3. Functions defined in class
class Rectangle {
  constructor(height, width) {
    this.height = height;
    this.width = width;
  }
}
//Function declarations will be raised
//Class declarations will not be promoted

24. Tell a joke

Peggy came home from school one day and complained to his mother, "My classmates say I look like a hair dryer."
Mom looks at page calmly: just talk, don't talk to me.

25. Deep copy

//Method 1
JSON.parse(JSON.stringify())
//Method 2 ES6
const arr1=[1,2,3];
const arr2=Array.from(arr1)
//Method 3
//Clone Deep with lodash
//Method 4 concat returns a new array

Topics: Javascript npm Mobile JSON