The HTTP protocol

Original text: juejin. Cn/post / 697721…

1. Differences between POST and GET
1.GET is harmless when the browser falls back, whereas POST resubmits the request;2.The URL generated by GET can be bookmarked, but POST cannot.3.GET requests are actively cached by browsers, whereas POST is not, unless set manually;4.GET requests can only be encoded by URL, while POST supports multiple encoding methods.5.GET request parameters are retained in browser history, while POST parameters are not.6.GET requests send parameters in the URL with length limits, whereas POST is unlimited.7.For parameters, GET accepts only ASCII characters, while POST has no restrictions.8.GET is less secure than POST because parameters are exposed directly in the URL and are not used to pass sensitive information;9.The GET argument is passed through the URL, and the POST is placed in the Request body.Copy the code
2. Main features of THE HTTP protocol class
Simple fast, flexible, connectionless, stateless.Copy the code
3.HTTP protocol class, HTTP method:
GET, obtain a resource, POST, transfer a resource, PUT, update a resource, DELETE, DELETE a resource, HEAD, obtain the packet HEAD.Copy the code

Deep copy Shallow copy

Original text: juejin. Cn/post / 693450…

Shallow copy
function shallowClone(obj) {
  let cloneObj = {};
  
  for (let i in obj) {
    cloneObj[i] = obj[i];
  }
  
  return cloneObj;
}
Copy the code
Deep copy
function deepClone(obj) {
  if (typeof obj === 'object') {
    let result = Array.isArray(obj) ? [] : {}
    for (let i in obj) {
      result[i] = deepClone(obj[i])
    }
    return result
  } else {
    return obj
  }
}
Copy the code