tags: js javascript
array.reduce(function(total, currentValue, currentIndex, arr), initialValue)var numbers = [65, 44, 12, 4];
function getSum(total, num) {
return total + num;
}
function myFunction(item) {
document.getElementById("demo").innerHTML = numbers.reduce(getSum);
}
Encapsulate commonly used js functions Get the request parameters in the current page url Splice url and parameters (json) Vue http request (get) Native http request (get) Native http request (jsonp) ...
yh-js-Kit git: github.com/Michaelhooo… AboutCookie setCookie(name, value) getCookie(name) delCookie(name) arrayFlattening steamroller arraySortByKey arraySortByKey changeDigitalDisplay formatTh...
First, the function page loads addLoadEvent () Since window.onload can only bind a command, when a plurality of instructions is bound, the last that will only function is actually carried out. In this...
table of Contents Array/Object An array of selected elements to retain Object of the array of key String String from the start position reserved Precise decimal digits, rounding Array/Object An array ...
As a function of binding parameters Description: The function passed as a parameter, using the closure as a function of binding parameters to be passed. Scenario: You can not specify parameters for th...
Deep clone objects Date format Get the file extension Detect empty objects Randomly generate n ~ m character strings Randomly generate colors...
Functions commonly used in js development String to number String to array Merge object properties (useful in configuration data merge)...
Math object There are many built-in objects in JS. Among them, the Math object encapsulates many commonly used mathematical functions. Math.random This method is used to generate a random number 0~1 c...