javaScript lazy load function
Due to browser differences, most js code contains a large number of if statements to guide the program to execute correctly. Examples are as follows:
function createXHR() {
if (typeof XMLHttpRequest != "undefined") {
return new XMLHttpRequest(); //Returns an instance of XMLHttpRequest when the XMLHttpRequest type is not ...
Added by bradjinc on Thu, 21 Oct 2021 21:15:23 +0300
-Set, Map, (Weak), Symbol and BigInt
set and map: these two data structures should be constructed through new. The parameters received by two data structures, one is a one-dimensional array and the other is a two-dimensional array.
1, Set data structure
A Set is actually a data structure similar to an array. The difference is that there are no duplicate basic type values or ...
Added by lastcraft on Tue, 12 Oct 2021 21:36:46 +0300
Loop call asynchronous operation
Recently, I met an interesting interview question. The question is very simple, but it involves a lot of small knowledge points. It's quite interesting.
An ordinary for loop outputs i
// Normally write a for loop and output i
for (var i = 0; i < 5; i++) {
console.log(i);
}
console.log(i);
Suppose you are an interviewer, what will t ...
Added by pikemsu28 on Tue, 12 Oct 2021 06:39:26 +0300
Learning ES6 Series: Basic Understanding and Use of generator
Ask yourself a few more questions each day about why, and you will always get unexpected results. A copyer for beginners
Preface
Today is the second day of National Day, come back home, or be bored, or write code. After all, the code is small and white, there is still a lot to learn, come on!
Recently I was learning redux-saga as a middl ...
Added by Mirge on Sat, 02 Oct 2021 19:16:32 +0300
ES6: enhanced object writing & deconstruction & let/const
Enhanced writing of objects
When defining the properties and methods of objects, it has a more convenient and simple way to write
var name = "fzb";
var age = 21;
var address = "address";
var info = {
name: name,
// A simple way to write attributes
age,
say: function () {
console.log(this.name + " say~");
},
// A simple wa ...
Added by vandalite on Sat, 02 Oct 2021 02:03:25 +0300
Classes, Symbols, Objects, and Decorations
Classes, Symbols, Objects, and Decorations
class
Use of classes // Declaration of class
class Fruit {
}
// Equivalent to the declaration of a constructor
function Fruit() {
}
Note: Class declarations differ from constructor declarations: Class declarations are not scoped ahead of time Properties and methods of classes
Constructor ...
Added by NFWriter on Sun, 26 Sep 2021 22:25:06 +0300
I see the wonderful "inheritance" of JavaScript
Inheritance plays an important role in various programming languages. Due to the "natural" flexibility of JavaScript, JS urgently needs a reusable and standardized solution in some scenarios. Classes and inheritance naturally appear in the public's vision.
With the continuous in-depth study of JavaScript, we suddenly found that the c ...
Added by grahamb314 on Wed, 22 Sep 2021 19:44:07 +0300
webpack -- five core concepts, basic usage and packaging
webpack
webpack is a front-end resource component tool, a static module bundler. Compile syntax that the browser does not recognize into syntax that the browser can recognize
From the perspective of webpack, many resource files (js/json/css/img/less) in the front end will be processed as modules. It will conduct static analysis according to t ...
Added by troublemaker on Tue, 21 Sep 2021 00:40:13 +0300
ES6 -- let const Symbol deconstruction assignment
1, let const
(1) let
1. Declared variables can only be valid within the current scope (the scope is {})
var is valid in the global scope (because the variables declared by var are on the whole object of Windows)
example: Because the let will be invalid if it lists the current scope, each time the for loop goes, it is equivalent to ...
Added by dayang on Mon, 13 Sep 2021 21:30:02 +0300
Seven ways to implement inheritance in javascript
Inheritance is the basic concept of object-oriented language. Generally OO language supports two ways of inheritance: interface inheritance and implementation inheritance. Interface inheritance only inherits method signature, while implementation inheritance inherits the actual method. The function in ECMAScript is not signed, so interface i ...
Added by Alith7 on Mon, 18 May 2020 04:00:39 +0300