//получаем все ссылки
const domains = document.querySelectorAll('a[href]');
// проходимся по всем ссылкам и формируем новый массив с ссылками
const urls = [...domains].map(item => new URL(item.href).host);
// переводим массив в строку и выводим
alert(urls.join(','))
Object.assign({}, [1,2,3,4,5]); // {0: 1, 1: 2, 2: 3, 3: 4, 4: 5}
Object.assign({}, ['a','b','c']); // {0: "a", 1: "b", 2: "c"}
{...[1,2,3,4,5]} // {0: 1, 1: 2, 2: 3, 3: 4, 4: 5}
Object.fromEntries(Object.entries([1,2,3,4])); // {0: 1, 1: 2, 2: 3, 3: 4, 4: 5}
window.open('https://www.google.com/', 'frame', 'width=500,height=500')
const chunk = (a, n) => a.length > 1 ? [...Array(Math.ceil(a.length / n))].map((_, i) => a.slice(n * i, n + n * i)) : a;
console.log(chunk([0], 2));
let id = 1, name = 'test name', price = 100
const oldArr = [
{ id, name, price},
{ id, name, price},
{ id, name, price}
]
const newArr = oldArr.map(item => ({
code: item.id,
orderName: item.name,
orderPrice: item.price
}))
console.log(newArr)
class Scrolling {
offset = null;
scrolls() {
const isOffset = pageYOffset > 100 ? "offsetOne" : "offsetSecond";
if (this.offset != isOffset) {
this[isOffset]({
registion: document.querySelector("#registion"),
vhod: document.querySelector("#vhod"),
});
this.offset = isOffset;
}
}
offsetOne({ registion, vhod }) {
registion.style.display = "none";
vhod.style.cssText = "background:none;width:30px";
vhod.innerHTML = "<img style='width: 20px; height: 20px;' src='SiteImage/logo_vhod.svg'>";
PanelMenuLinks.style.cssText = "background:none;z-index:-1;margin-top:-45px;font-size:13px;color:#fff;border-top:0;";
block_panel_menu_children.style.top = "10px";
//block_panel_menu - заменить на класс.
document.querySelectorAll("#block_panel_menu").forEach((item) => (item.style.height = "49px"));
document.querySelector("#logotip").style.cssText = "opacity: 0;margin-top:-20px;";
document.querySelector("header").style.height = "50px";
}
offsetSecond({ registion, vhod }) {
registion.style.display = "block";
vhod.style.cssText = "background:#626262;width:100px";
vhod.innerHTML = "Регистрация";
PanelMenuLinks.style.cssText = "background:#E7E7E7;margin-top:0px;font-size:18px;color:#000;border-top:10px solid #fff;";
block_panel_menu_children.style.top = "20px";
//block_panel_menu - заменить на класс.
document.querySelectorAll("#block_panel_menu").forEach((item) => (item.style.height = "70px"));
document.querySelector("#logotip").style.cssText = "opacity:1;margin-top:0px;";
document.querySelector("header").style.height = "70px";
}
}
const scroll = new Scrolling();
window.addEventListener("scroll", scroll.scrolls.bind(scroll), false);
class MyClass {
method() {
console.clear();
console.log(Reflect.has(this, 'secondMethod')) // true
console.log(this.hasOwnProperty('secondMethod')); // false
console.log('secondMethod' in this) // true
console.log(this.secondMethod !== undefined) // true
}
secondMethod() {
}
}
let myClass = new MyClass();
myClass.method();
function compare(one = '', second = '') {
let oneArray = one.match(/([a-zA-Z]+)|(\d+)/g);
let secondArray = second.match(/([a-zA-Z]+)|(\d+)/g);
if (oneArray && oneArray[0] > 10) return false;
if (!oneArray || !secondArray) return false;
if (oneArray[0] != secondArray[0]) return false;
if (parseInt(oneArray[1]) < parseInt(secondArray[1])) {
return true;
}
return false;
}
console.log(compare('ty12', 'ty33')); // true
console.log(compare('ty121', 'ty33')); // false
console.log(compare('ty121', 'tyt33')); // false
const chunk = (a, n) => [...Array(Math.ceil(a.length / n))].map((_, i) => a.slice(n * i, n + n * i));
console.log(chunk([0,1,2,3,4,5,6,7,8,9,10,11,12], 6));
//0: [0, 1, 2, 3, 4, 5]
//1: [6, 7, 8, 9, 10, 11]
//2: [12]
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://www.ozon.ru/category/muzhskaya-odezhda-7542/',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'GET',
));
$response = curl_exec($curl);
curl_close($curl);
$response;
dd($response);