``
– шаблонная строка`${variable}`
- переменная в такой строке, или любое выражение[]
- массив, доступ к элементу массива по индексу или ключуid.length-1
- обычное выражение, длина массива минус одинid[id.length-1]
- доступ к последнему элементу массиваlet lastIndex = id.length-1;
let lastElement = id[lastIndex];
`./articles/${lastElement}`
// Вызываем функцию, результат кладем в переменную
const result = myFunction();
// Обычное объявление
function muFuncion() { }
// Выражение с анонимной функцией
const myFunction = function() { }
// Выражение с именованной функцией
const myFunc = function myFunction() { }
// Объявление стрелочной функции
const myFunction = () => { }
someFunction(function() {}) // анонимка
someFunction(() => {}) // стрелочная
nvm on
nvm list
– посмотреть какие версии у вас установленыnvm current
– посмотреть текущую (покажет то же, что node -v
)props.medications
.filter(f => f.Purposes.findIndex(i => props.purpose === i.Purpose) > -1)
// Если ни одного нет, findIndex вернет -1,
// условие не выполнится и элемент отфильтруется.
https://programest.github.io/lang.json
https://programest.github.io/AdilPortfolio/lang.json
/lang.json
– слеш вначале означает, что путь к файлу на сервере будет определятся от корня, то есть грубо говоря от названия сайта, от домена. В данном случае от https://programest.github.io
function makeItem(title) {
return `<a class="dropdown-item"><i class="icon icon-line-circle"></i><span>${title}</span></a>`;
}
fetch('../russia.json')
.then(response => response.json())
.then(json => {
const itemsHtmlString = json.map(item => makeItem(item.city)).join()
$('.search__city .dropdown-menu').html(itemsHtmlString);
});
(function () {
const themeCheckBox = document.querySelector('#theme-toggle')
const themeLabel = document.querySelector('.theme-toggle')
themeLabel.addEventListener('click', () => {
- localStorage.setItem('themeCheckBox', themeCheckBox.checked)
+ localStorage.setItem('themeCheckBox', themeCheckBox.checked ? '1' : '')
})
- themeCheckBox.checked = localStorage.getItem('themeCheckBox')
+ themeCheckBox.checked = !!localStorage.getItem('themeCheckBox')
})()
themeCheckBox.checked = localStorage.getItem('themeCheckBox')==='true'
if ( currentUrl.replace(/^\/|\/$/g, '') === [rootUrl.replace(/^\/|\/$/g, ''), relativeUrl.replace(/^\/|\/$/g, '')].join('/') ){
}
window.location.href
может содержать query string и hash string.new URL(window.location.href)
) и уже из этого объекта собирать URL domain + pathname.