Edit role permission Edit permission Query route assignment
this.$router.push({name:'monitoringDetail'.query: {id: id}});
this.$router.push({ name: 'home'.params: { userId: wise }})
this.$router.replace('position');
this.$router.go(-1);
const {href} = this.$router.resolve({ name: 'srvbotReqDetail', query})
window.open(href, '_blank');
Copy the code
Execution context
Variable/function promotion validation scope/chain validation this refers to constructor prototype/chain data type (stack, heap)
Scope and scope chain (closure)
Global scope functions scope block-level scope
Variable promotion/function promotion (promote function declaration first and then promote variable declaration)
(ERROR ‘fun’ has already been declared)
letFun = 'fun'function fun () {}
Copy the code
This points to the
Function Test() {return this} Test() this points to the window object. New Test() this points to the instance object
- Module.exports function test() {this === global} global name = ‘node.js’ to global this.name = ‘node.js’ to module.exports function test() {this === global} to global
- Browser global
Name = ‘win’ points to window
Object key value traversal outputlet obj = { name: "zhu".age: 24[Symbol("bar")]: "symbol-bar" } Copy the code
- Symbol attribute
- Object.defineproperty (obj, “age”, {Enumerable: false}) cannot be enumerable
- Obj. Proto = {fa: “father”} attribute on the stereotype
for (let key in obj) {}
for (let key of obj) {}
Object.keys(obj) name
Object.getOwnPropertyNames(obj) name age
Object.getOwnPropertySymbols(obj) Symbol("bar")
Reflect.ownKeys(obj) name age Symbol("bar")
Copy the code
Memory leak -> Memory overflow
- Unexpected global variables
- Forgotten timer or callback function
- Out-of-dom references
- closure
The difference between arrow functions and normal functions:
- Function test () {} arrow () =>{}
- Arrow functions cannot be used for constructors
function Person(name,age){ this.name=name; this.age=age; } let admin=new Person("Enno Strings.".18); console.log(admin.name); console.log(admin.age); Copy the code
- This points differently
- The arrow function’s this always points to its context’s this, Call (obj,a,b) fn, fn.bind(obj,[a,b]), fn.apply(obj,a,b) document.onclick = fn.call(obj); Document.onclick = fn.bind(obj); Preprocessing this points to, and click executes fn
- The this of an ordinary function refers to the object on which it was called
Prototype and Prototype Chain (Class)
JavaScript prototype inheritance implementation
- Define a new constructor and internally call the constructor you want to “inherit” with call() and bind this;
- Inherits the prototype chain with an intermediate function F, preferably with the encapsulated inherits function.
- Continue to define new methods on the prototype of the new constructor.
function inherits(Child, Parent) {
var F = function () {};
F.prototype = Parent.prototype;
Child.prototype = new F();
Child.prototype.constructor = Child;
}
Copy the code
es6 class extends
Super refers to the parent class
Class Rabbit extends Animal {
hide() {
alert(`The ${this.name}hides! `);
}
stop() {
super.stop();// Call the stop function of the parent class
this.hide();// Then hide}}Copy the code
What are the data types of JS and where are they stored
- Basic data type, stored on the stack
- Boolean(B)
- String(S)
- underfined(N)
- Null(N)
- Number(N)
- Symbol (ES6)
- Refers to a data type (complex type) that exists in the heap and holds a pointer to the address in the heap
Shallow copy (data type reasons)
let obj = {a: 1, b: 2};
Light:
- Object.assign()
Object.assign({}, obj); - Destruct assignment {… obj};
Deep:
- JSON. Parse and JSON. Stringfy
function deepClone(obj){ let _obj = JSON.stringify(obj),// Convert the JSON object to a string objClone = JSON.parse(_obj);// Convert the JSON string to an object return objClone } export default deepClone Copy the code
- Deeper level
CloneDeep (obj) lodash librarylet obj = { a: 'a'.b: ‘b’, c: { cc: 'cc'}} newObj = obj; The assignmentnewNewObj = {... obj }; Shallow copynewChange, a and B remain the same, cc change _obj =JSON.stringify(obj); newObj = JSON.parse(_obj); newGetting old is constantCopy the code
What does the new operator do
- Create an empty Object var obj = new Object();
- Set the prototype chain (when a constructor is called to create a new instance, the instance will contain a pointer (internal property) to the constructor’s prototype object) obj.proto= func.prototype;
- Var result = func.call (obj); let this in Func refer to obj and execute the function body of Func (after creating a new object, assign the scope of the constructor to the new object (so this refers to the new object).
- Determine the return type of Func: if it is a value type, return obj. If (typeof(result) == “object”){func=result; }else{ func=obj;; }
Native new
function Foo(name) {
console.log(this)
this.name = name;
console.log(this)
return this;
};
function _new(Func, ... args) {
let obj = {};
obj.__proto__ = Func.prototype;
letresult = Func.call(obj, ... args);return result || obj;
}
Copy the code
The original call
Function.prototype._call = function(arg, ... args) {
arg.fn = this;
letres = arg.fn(... args);delete arg.fn;
return res;
};
Copy the code
Instanceof principle
function instance_of(L, R) { // stu; R is the Person
var O = R.prototype; / / O for the Person. The prototype
L = L.__proto__; // L is stu._proto_, which now points to the per instance object
while (true) { // Execute the loop
if (L === null) return false; / / not through
if (O === L) return true;
L = L.__proto__; // set L = stu._proto_._proto_, and execute the loop
} // stu._proto_._proto_.
} // Refers to person.prototype, so return true
Copy the code
Encryption problem
- HASH HASH
MD5
SHA
encryptionHMAC
encryption
- Symmetric encryption
- Data Encryption Standard (DES) : Data Encryption Standard (rarely used nowadays because its Encryption strength is not strong enough for brute force cracking)
- 3DES: Encrypts the same data three times with three keys to enhance the encryption strength. (Disadvantages: Three keys need to be maintained, greatly increasing the maintenance cost)
- Advanced Encryption Standard (AES) : Currently used by the NSA and used by Apple for keychain access. It is now recognized as the most secure encryption method and the most popular algorithm in symmetric key encryption.
- Asymmetric encryption
RSA
Encryption (jsencrypt.js package)sm2
(Company Account Link Service)
https
(http+ssl)
Asymmetric encryption + symmetric encryption
Buried point of front-end monitoring (event tracking)
- Destination data Monitoring (listening to user behavior)
Performance Monitoring
Exception monitoring (sentry.js, better.js, Logan)
sentry
: Work with SourceMaps in WebPack build to locate exceptions) - Buried point visualization buried point (Baidu statistics, Umeng) no trace buried point (full buried point)
- Buried point attributes, events, cycles, data encryption, visual presentation