JSFiddle - React, Tailwind, and code Playground

by obobruyko

HTML

<a href="#" id = "source">Source</a>
<a href="#" id = "target">Target</a>

JavaScript

function addHideHandler(sourceId, targetId) {

    // создан объект [[scope]] со свойствами sourceId, targetId
    // записать в [[scope]] свойство sourceNode

    var sourceNode = document.getElementById(sourceId);

    // записать в [[scope]] свойство handler

    var handler = function() {
        var targetNode = document.getElementById(targetId),
            display = targetNode.style.display === 'none' ? 'inline' : 'none';

        targetNode.style.display = display;
    }

    sourceNode.onclick = handler;

    // функция закончила выполнение
    // (***) и тут - самое интересное!

}

addHideHandler("source", "target");