function generateArrayOfYears(year) {
var max = new Date().getFullYear()
var years = []
for (var i = year; i <= max; i++) {
years.push(i)
}
return years
}
console.log(generateArrayOfYears(2015)) // -> [2015, 2016, 2017, 2018, 2019, 2020, 2021]
submitHandler: function(form) { // <- pass 'form' argument in
$(".submit").attr("disabled", true);
form.submit(); // <- use 'form' argument here.
}
export default function detectAdBlock(){
return new Promise((resolve) => {
const adElement = document.createElement("div");
adElement.classList.add('adsbygoogle');
adElement.style.cssText = 'height: 1px; width: 1px; background-color: transparent';
document.body.appendChild(adElement);
const adElementStyle = getComputedStyle(adElement, null);
window.setTimeout(()=>{
if(adElementStyle.display === 'none'){
resolve(true)
}else{
resolve(false)
}
document.body.removeChild(adElement);
}, 20)
})
}
const a = document.URL //=> https://qna.habr.com/q/980157
a.slice(0, a.lastIndexOf("/")) //=> https://qna.habr.com/q
let arr = [6, 2, 1, 1, 3, 15]
arr.sort((a,b) => a-b ) //-> [1, 1, 2, 3, 6, 15]
arr.pop() //-> [1, 1, 2, 3, 6]
arr.shift() //-> [1, 2, 3, 6]
или
const newArr = arr.slice(1, -1) //-> [1, 2, 3, 6]
let obj ={
algebra: [3, 4, 5, 3, 4, 5],
geometry: [4, 5, 4, 3, 5],
physics: [5, 4, 3, 5, 4, 4],
}
for (let key in obj) {
console.log(key, obj[key].reduce((a,b) => a+b)/obj[key].length)
}
// -> "algebra", 4
// -> "geometry", 4.2
// -> "physics", 4.166666666666667
let b = [1, 2, 3, 0, 4, 5, 6];
const sum = b.slice(0, b.findIndex(e => e === 0)).reduce((total, amount) => total + amount);
console.log(sum)
import $ from “jQuery”;
window.$ = window.jQuery = $;
if(window.jQuery && window.$) { const somePlugin = import(“pathtoplugin”); }
Или
if(window.jQuery && window.$) { const somePlugin = require(“pathtoplugin”); }
...
mounted: function(){
$('#selector').somePlugin({
// ... настройки плагина
});
}
...
jQuery.ajax({
type: "POST",
url: 'YOU_URL_TO_WHICH_DATA_SEND',
data:'YOUR_DATA_TO_SEND',
beforeSend: function() {
$("#loader").show();
},
success: function(data) {
$("#loader").hide();
}
});
document.querySelector('input').value= '' ;