Tag:js

  • How to implement enumeration with JS emulation

    Time:2022-6-9

    preface In current JavaScript, there is no concept of enumeration. Using enumeration in some scenarios can better ensure the correctness of data and reduce the data verification process. Here is how JavaScript simulates the enumeration effect. Enumeration main features Enum value cannot be repeated Cannot be modified realization let days; (function (days) { days[days[“Sunday”] = […]

  • Top 10 JS image processing libraries

    Time:2022-6-3

    catalogue introduce 1.Pica 2. Lena.js 3. Compressor.js 4. Fabric.js 5. Blurify 6. Merge Images 7. Cropper.js 8. CamanJS 9. MarvinJ 10. Grade introduce For many people, using JavaScript to process images is not a very simple thing. Fortunately, we can use third-party libraries to achieve the functions we want. This article introduces what JavaScript image […]

  • Why await outperforms promise in JS asynchronous stack tracing

    Time:2022-6-2

    summary The fundamental difference between async/await and promise is that await fn() suspends the execution of the current function, while promise Then (FN) continues to execute the current function after adding the FN call to the callback chain. const fn = () => console.log(‘hello’) const a = async () => { Await fn() // pause […]

  • 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 […]