Apologies for the bad title or question. But to make it easier understand I have a code here that calls the header multiple times for example. The variable below specifies the element to clone which is #header a[href=$=programs]. The ID #header is called multiple times in parts of my code. Is there a way to call it once and insert it in parts of my code instead of adding it manually. I'm still new to javascript. I hope I managed to explain it well despite my lack of understanding on programming.    var programsMenu = [];        programsMenu.push($('#header a[href$=/programs]').clone());        programsMenu.push($('#header a[href$=/programs]').next().clone());    var degreesMenu = [];        programsMenu.push($('#header a[href$=/programs]').clone());        degreesMenu.push($('#header a[href$=/degree-programs]').clone());        degreesMenu.push($('#header a[href$=/degree-programs]').next().clone());(function ($) {    'use strict';    var footerNavigation = {        init : function() {            var programsMenu = [];                programsMenu.push($('#header a[href$=/programs]').clone());                programsMenu.push($('#header a[href$=/programs]').next().clone());            var degreesMenu = [];                programsMenu.push($('#header a[href$=/programs]').clone());                degreesMenu.push($('#header a[href$=/degree-programs]').clone());                degreesMenu.push($('#header a[href$=/degree-programs]').next().clone());            $('#footer .programs-menu .degree').append(degreesMenu);            var nonDegreeMenu = [];                nonDegreeMenu.push($('#header a[href$=/executive-education-programs]').clone());                nonDegreeMenu.push($('#header a[href$=/development-education-programs]').clone());                nonDegreeMenu.push($('#header a[href$=/program-schedules]').clone());            $('#footer .programs-menu .non-degree').append(nonDegreeMenu);            var schoolMenu = [];                schoolMenu.push($('#header a[href$=/schools]').clone());                schoolMenu.push($('#header a[href$=/schools]').next().clone());                $('#footer .schools-faculty-menu .schools').append(schoolMenu);            var facultyMenu = [];                facultyMenu.push($('#header a[href$=/faculty-and-staff]').clone());                facultyMenu.push($('#header a[href$=/faculty-and-staff]').next().clone());                 $('#footer .schools-faculty-menu .faculty').append(facultyMenu);            // var researchMenu = [];            //     researchMenu.push($('a[href$=/research-centers]').clone());            //     researchMenu.push($('a[href$=/research-centers]').next().clone());            var researchCenters  = $('#header a[href$=/research-centers]').next().clone(),                centersList      = $('li', researchCenters),                research         = $('#footer .research-centers-menu .research'),                publications     = $('#footer .research-centers-menu .publications'),                publicationsMenu = $('<ul class=menu />').appendTo(publications),                researchMenu     = $('<ul class=menu />').appendTo(research),                centers          = centersList.slice(0, 6),                resources        = centersList.slice(6);            //Store Research anchor and AIM Research Centers             var aimResearchCenters = [];                aimResearchCenters.push($('#header a[href$=/research-centers]').clone());                aimResearchCenters.push($(researchMenu.append(centers)));            //Append aimResearch array            $('#footer .research-centers-menu .research').append(aimResearchCenters);            publicationsMenu.append(resources);            /*            $('#footer .research-centers-menu .research').append(centers);            $('#footer .research-centers-menu .publications').append(resources);            */            var aboutMenu = [];                aboutMenu.push($('a[href$=/about-us]').clone());                aboutMenu.push($('a[href$=/about-us]').next().clone());            $('#footer .about-menu .about').append(aboutMenu);            //Duplicate Breadcrumns on header and insert it on footer            var breadcrumbs = $('.region-breadcrumb').clone();            $('.region-breadcrumb').clone().insertAfter('#footer .footer-head');        }    }    $(document).ready(function() {        footerNavigation.init();    })})(jQuery);
Lessen redundant calls/lookups from a class or ID
jquery;html