const SHOW_INITIAL = 3;
const SHOW_MORE = 5;
const listSelector = '.myList';
const itemSelector = 'li';
const showSelector = '.loadMore';
const hideSelector = '.showLess';
$(listSelector)
.on('click', showSelector, function({ delegateTarget: t }) {
$(`${itemSelector}:hidden`, t).slice(0, SHOW_MORE).show();
})
.on('click', hideSelector, function({ delegateTarget: t }) {
$(`${itemSelector}:visible`, t).slice(SHOW_INITIAL).slice(-SHOW_MORE).hide();
})
.each(function() {
$(itemSelector, this).slice(0, SHOW_INITIAL).show();
});