I am new to JS and I am trying to figure out the most efficient way to perform this task.
Stack Exchange keeps a list of its member-sites at https://stackexchange.com/sites
What is the most efficient way to extract this data into a data-structure, like an array or dictionary in JavaScript?
It seems like all the stackexchange sites are built with the same framework. If you check in your console, you can see that a javascript object StackExchange
is defined on any stackexchange site.
If you just want to scrape that link in your question, you can go there in your browser, and type this in your console: $('.gv-item-collapsed-wrapper h2').text()
That page already has jQuery loaded, which you can use to search through elements on the page. That code snippet will show you all the site titles in a string.
Better yet (but a little more complex)
var arr = [];
$('.gv-item-collapsed-wrapper h2').each(function(){arr.push($(this).text())});