read a number, such as 521
change this number to 0521
but put it into four div separately, how to realize it?
let n = 521; //
n = (n*1).toString().padLeft(4,'0');
for(let v of n){
let dom = document.createElement('div');
dom.innerText = v;
//dom appendTodom
}
-
In the chained promise function, how to determine which promise threw the error
I need to implement in a chained promise function, any function error in the middle terminates the program, and can catch the error function, and then perform different operations according to different error functions. How can the following code be imp...
Feb.26,2021 -
How to use Generator to implement a chain dependent function?
how do I use generator to achieve the following functions? function f1(){ return new Promise((resolve,reject) =>{ setTimeout(() =>{ resolve(1); },1000) }) } function f2(valu...
Feb.27,2021 -
This problem of js Arrow function
I don t understand why this is window in this broken code. Thank you for your understanding. Thank you. var o = { fn:() => { console.log(this) } } o.fn() ...
Feb.28,2021 -
How does js implement a general regular validation form method (minimum code)
1. How to implement a general regular validation form with the least amount of code = project, 1. Login has two input (verify mailbox, password 10 digits + letters) 2. input () both forms are displayed after input loses focus (correct or w...
Mar.01,2021 -
I want to use some of the constants defined in state to assign default values to the drop-down box and v-model this variable in the data of the component, what should I do?
I m going to assign the default value of 1 to the value of the drop-down box and bind this variable; <select v-model= selectValue >< select> but just let data(){ return{ selectValue:1 } } this type of writing is not readable, so I ...
Mar.03,2021 -
Convert js to timestamp
converts the current time to a timestamp and saves it to localStorage. uses another time to generate a timestamp to determine whether the interval between the two is greater than one month. or not switch to a timestamp, as long as you can determine t...
Mar.03,2021 -
What is the most elegant way to implement an array of ES6 objects based on a property?
A solution that conforms to the meaning of the question function unique(arr) { const res = new Map(); return arr.filter((a) => !res.has(a) && res.set(a, 1)) } because map key is unique, you can change the an in res.has (a) to whate...
Mar.03,2021 -
How to understand closures
1. Use var: var a = []; for (var i = 0; i < 10; iPP) { a[i] = function () { console.log(i); }; } a[6](); 10 2. Use let var a = []; for (let i = 0; i < 10; iPP) { a[i] = function () { console.log(i); }; } a[6](); 6 quest...
Mar.03,2021 -
Es6, removes the contents of one array from another array
my code has bug, and then I checked to write = = as = . A [1,2,3,4,5,6,7] B [2,3,4] after deletion A [1,5,6,7] this.selectRightTableData.forEach(item => { this.rightTableData.splice(this.rightTableData.findIndex(v => v.id = item.id...
Mar.03,2021 -
How to handle asynchronous queuing in dva
* deleteDetails({payload}, {call, put}) { const result = yield call(deleteDetails, {payload}); if (result.code !== 200) { throw result.msg; } else { Toast.success(result.msg, 1); yield put(routerRedux.goBack(...
Mar.04,2021 -
How does es6's Set customize the de-repetition rules? How can an array of objects be duplicated according to a column property?
for example, duplicates according to the name attribute in the an array element. is this the simplest way? function unique(arr) { const res = new Map(); return arr.filter((a) => !res.has(a.name) && res.set(a.name, 1)) } reference...
Mar.04,2021 -
Deconstruction of ES6- function
The deconstruction of the function does not quite understand the red arrows in this. Why undefined? Is it not true that when let {XMagi y} = {XRO 0PersonyGl} , x can output equal to 0LI YQ 1, although XMagi y is a pattern and the assignment is assig...
Mar.04,2021 -
JS rendering output string concatenation html should not have a comma
navMenuData.sort(sortID).map((item) => { let option; if (item.options) { let optionJSON = JSON.parse(item.options) option = optionJSON.map((item) => { return `<a href="-sharp">${item.name}< a>` ...
Mar.05,2021 -
What is the most elegant way for js to add another array to the end of the array?
is there a method like push, but instead of inserting an element into an array, add another array similar to java s addAll method all I know so far is concat, but he returns the new array instead of making changes on the original array, ...
Mar.06,2021 -
The problem of clock function in Generator function in ES6
var clock = function*() { while (true) { console.log( Tick! ); yield; console.log( Tock! ); yield; } }; you can see that the state machine implemented by the Generator function does not need to set initial variables or switch ...
Mar.10,2021 -
It doesn't matter how gracefully es6 judges that the values contained in two arrays are exactly the same.
this is what I do now. Is there a better way? let flag = true const listA = [1, 2, 3] const listB = [2, 3, 4] if (listA.length !== listB.length) { flag = false } else { listA.forEach(item => { if (listB.indexOf(it...
Mar.10,2021 -
Solve the problem of array processing?
let keys = [ a , b ] let vals = [ [111, 222], [333, 444] ] expected result: [{a:111,b:222},{a:333,b:444}] ...
Mar.14,2021 -
Js array operation
var str = "abc-a,add-a,ccc-b,ccc-d,abc-a,abc-b,abc-f,tbg-g "; convert the above string to the following array form: var arr = [ {"name" : "abc", "nameIdx":[{"site" : "a"}]}, {"name"...
Mar.14,2021 -
How to transfer parameters asynchronously by js?
I have several asynchronous function operations, but I want these asynchronous operations to be performed sequentially, I want to use queues, and each function needs to pass parameters. I think of the middleware of koa2, but how do I implement it? Or is ...
Mar.17,2021 -
About the understanding of the default values of es6 function parameters?
var x = 1; function foo(x, y = function() { x = 2; }) { var x = 3; y(); console.log(x); } foo() 3 x 1 the above is the penultimate example of the scope of the function in the book introduction to es6 written by teacher Ruan Yifeng . Teache...
Mar.18,2021
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1c1d415-33379.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1c1d415-33379.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?