let initial = 0;
department.reduce(function callback(prev, current) {
return prev + current.salary
}, initial);
let tm;
function event_search(event) {
let search_value = event.target.value;
clearTimeout(tm);
tm = setTimeout(() => {
axios.post(document.location.pathname, { search_value }, { headers })
.then(function (res) {
console.log(res)
document.querySelector('#search').innerHTML = res.data
})
.catch(e => {
console.log(e)
})
},200)
}
займет какое то время, это значить за компом 24/7, с друзьями вообще итак почти не вижусь, а тут совсем крыша поедет, но зато приду к той цели, о которой мечтал
function _isElementVisible(element) {
let rect = element.getBoundingClientRect();
let vWidth = window.innerWidth || doc.documentElement.clientWidth;
let vHeight = window.innerHeight || doc.documentElement.clientHeight;
if (rect.right < 0 || rect.bottom < 0 || rect.left > vWidth || rect.top > vHeight) return false;
return (
element.contains(document.elementFromPoint(rect.left, rect.top))
|| element.contains(document.elementFromPoint(rect.right, rect.top))
|| element.contains(document.elementFromPoint(rect.right, rect.bottom - 1))
|| element.contains(document.elementFromPoint(rect.left, rect.bottom - 1))
);
}
try{calc_tiles__width_tile.val(eval('calc_tiles__width_tile.val()'))}
catch(e){console.log("Не получилось!")}
deepEqual
возвращает отсортированный объект.if (typeof key === "object") {
deepEqual(key)
}
if (typeof key === "object") {
obj[key] = deepEqual(key)
}
obj = Object.fromEntries(sort);
for (let key in obj) {
if (!obj.hasOwnProperty(key)) continue;
let subObj = obj[key];
if (typeof subObj === "object") {
obj[key] = deepEqual(subObj)
}
};
Why Lodash?
Lodash makes JavaScript easier by taking the hassle out of working with arrays, numbers, objects, strings, etc.
Lodash’s modular methods are great for:
- Iterating arrays, objects, & strings
- Manipulating & testing values
- Creating composite functions
function getData(){
return $.ajax({
type: "POST",
url: "getdata.php",
});
}
getData.done(function(data){
alert(data);
});
async function getData() {
return new Promise(function(resolve, reject) {
$.ajax({
type: "POST",
url: "getdata.php",
success: function (msg) {
resolve(msg);
},
error: function (response) { // Данные не отправлены
reject('Ошибка. Данные не отправлены.');
}
});
});
}
let data = await getData();