Tag:js

  • JS object constructor object Freeze

    Time:2022-5-30

    catalogue summary Example 1) Freeze objects 2) Freeze array 3) Shallow freezing 4) Deep freezing Meaning of existence summary Object Freeze (obj) can freeze an object. A frozen object can no longer be modified; If an object is frozen, you cannot add a new attribute to the object, delete an existing attribute, modify the enumerability, […]

  • [js] portable XMLHttpRequest application function: downloadurl()

    Time:2022-5-29

    Some time ago, when using the function library of the Google map API, I found that the downloadurl function is very easy to use, so I wrote one myself. I’m tired of using those frameworks and pools. In the end, I find that the simpler things are more suitable for lazy people like me. downloadUrl(url, callback, data); […]

  • How JS adds abort function to promise

    Time:2022-5-29

    catalogue summary Promise race method Repackage promise AbortController  Axios plug-in has its own cancellation function summary Promise has only three statuses: pending, resolve, and reject. Once an asynchronous commitment is issued, after waiting, it can only be success or failure, and cannot be canceled halfway. There are two ways to provide abort function for promise: […]

  • More features of JavaScript console

    Time:2022-5-27

    catalogue summary console.log console.info console.warn console.error console.table console.assert console. Group and console groupEnd conclusion summary You may have used console in JavaScript projects log。 This is a convenient way to view the value of a variable or what happens when the program is running. However, the JavaScript console object has many other functions that can […]

  • JS what scenario is not suitable for arrow function

    Time:2022-5-20

    catalogue summary Define methods on objects Object literal Object prototype Callback function of dynamic context Call constructor Abbreviated grammar summary summary Over the years, when ES6 has raised the usability of JS to a new level: arrow functions, classes, etc., these are great. Arrow function is one of the most valuable new functions. There are […]

  • How does JS understand data URL

    Time:2022-5-19

    catalogue summary Get to know data URL Data URL syntax Multilingual implementation of string Base64 encoding and decoding 1.unix  2.javascript  3.nodejs 4.python 5.php 6.java 7..net Data URL FAQ summary Canvas has a very common method Todataurl(), which converts canvas to the format of data URL.Usually, the type of this data URL is image.Take the following […]

  • JS object replication (deep copy and shallow copy)

    Time:2022-5-18

    catalogue 1、 Shallow copy 1、Object.assign(target,source,source…) 2. Extension operator (spread) 2、 Deep copy 1. Use object serialization JSON Stringify() and JSON parse() 2. Use recursion to judge the object properties 1、 Shallow copy 1、Object.assign(target,source,source…) a. Multiple object replication is supported b. If the source and target attributes are the same, source will copy the target attributes […]

  • HTML5 canvas + JS controls the camera instance on the computer or mobile phone

    Time:2022-5-15

    The client APIs on mobile devices and desktop computers were not synchronized at first. At first, there are always some functions and corresponding APIs on mobile devices, but slowly, these APIs will appear on desktop computers. One of the application interface technologies is getusermedia API, which allows application developers to access users’ cameras or built-in […]

  • How to use JavaScript verification mode

    Time:2022-5-14

    catalogue summary Form validation without policy mode Use policy pattern optimization Advantages of strategic mode summary summary In the web project, the login, registration and other functions require form submission. Before submitting the user’s data to the background, the front end generally needs to do some verification within its ability, such as whether to fill […]

  • 7 JS native error types you should know

    Time:2022-5-9

    catalogue summary 1. RangeError 2. ReferenceError 3. SyntaxError 4. TypeError 5. URIError 6. EvalError 7. InternalError summary summary From the browser console to run node JS terminal, we will see errors everywhere. The focus of this article is to outline the types of errors we may encounter in JS development. Tip: good error tips can […]

  • Talk about deconstruction in JS ES6

    Time:2022-5-7

    summary ES6 adds a new way to get specified elements from arrays or objects, which is what we want to talk about today. Let’s talk about the deconstruction of arrays first Before deconstruction, we usually get the specified elements in the array according to the index: const arr = [1, 2, 3]; const a = […]

  • JS ES6 asynchronous solution

    Time:2022-5-6

    catalogue The callback function is initially used ES6 asynchronous processing model API tailored for this asynchronous model: promise The callback function is initially used Because there was no clear specification in the original j s official, the parameters in the callback function transmitted from the asynchronous function encapsulated in various third-party libraries were not clearly […]