Skip to content

web search done right

fix inline code formatting in stackoverflow widget

Mikkel Denker13f58064d01f
diff --git a/core/src/api/webgraph.rs b/core/src/api/webgraph.rs
index 1b480458..ba8ed83a 100644
--- a/core/src/api/webgraph.rs
+++ b/core/src/api/webgraph.rs
@@ -50,6 +50,8 @@ impl RemoteWebgraph {
}
pub mod host {
+ use url::Url;
+
use super::*;
#[derive(serde::Deserialize, ToSchema)]
@@ -176,7 +178,9 @@ pub mod host {
extract::State(state): extract::State<Arc<State>>,
extract::Query(params): extract::Query<HostLinksParams>,
) -> std::result::Result<impl IntoResponse, StatusCode> {
- let node = Node::from(params.host).into_host();
+ let url = Url::parse(&("http://".to_string() + params.host.as_str()))
+ .map_err(|_| StatusCode::BAD_REQUEST)?;
+ let node = Node::from(url).into_host();
let links = ingoing_links(state, node, GraphLevel::Host)
.await
.map_err(|_| {
@@ -198,7 +202,9 @@ pub mod host {
extract::State(state): extract::State<Arc<State>>,
extract::Query(params): extract::Query<HostLinksParams>,
) -> std::result::Result<impl IntoResponse, StatusCode> {
- let node = Node::from(params.host).into_host();
+ let url = Url::parse(&("http://".to_string() + params.host.as_str()))
+ .map_err(|_| StatusCode::BAD_REQUEST)?;
+ let node = Node::from(url).into_host();
let links = outgoing_links(state, node, GraphLevel::Host)
.await
.map_err(|_| {
diff --git a/core/src/distributed/sonic/mod.rs b/core/src/distributed/sonic/mod.rs
index 03bd8157..d6b6f382 100644
--- a/core/src/distributed/sonic/mod.rs
+++ b/core/src/distributed/sonic/mod.rs
@@ -46,6 +46,9 @@ pub enum Error {
#[error("Could not build connection pool")]
PoolCreation,
+ #[error("The request could not be processed")]
+ BadRequest,
+
#[error("Other")]
Other(#[from] anyhow::Error),
}
diff --git a/core/src/entrypoint/webgraph_server.rs b/core/src/entrypoint/webgraph_server.rs
index 01525557..dd2cc624 100644
--- a/core/src/entrypoint/webgraph_server.rs
+++ b/core/src/entrypoint/webgraph_server.rs
@@ -115,7 +115,10 @@ impl Message<WebGraphService> for Knows {
type Response = Option<Node>;
async fn handle(self, server: &WebGraphService) -> sonic::Result<Self::Response> {
- let node = Node::from(self.host.to_string()).into_host();
+ let url = Url::parse(&("http://".to_string() + self.host.as_str()))
+ .map_err(|_| sonic::Error::BadRequest)?;
+
+ let node = Node::from(url).into_host();
if server.similar_hosts_finder.knows_about(&node) {
Ok(Some(node))
diff --git a/core/src/query/pattern_query.rs b/core/src/query/pattern_query.rs
index 5fcfe368..eeb7b4da 100644
--- a/core/src/query/pattern_query.rs
+++ b/core/src/query/pattern_query.rs
@@ -59,8 +59,8 @@ impl PatternQuery {
schema: &tantivy::schema::Schema,
fastfield_reader: FastFieldReader,
) -> Self {
- let mut field = Field::Text(field);
- let mut tv_field = schema.get_field(field.name()).unwrap();
+ let field = Field::Text(field);
+ let tv_field = schema.get_field(field.name()).unwrap();
if can_optimize_site_domain(&patterns, field) {
if patterns.len() == 3 {
@@ -68,11 +68,6 @@ impl PatternQuery {
unreachable!()
};
- if let Field::Text(TextField::UrlForSiteOperator) = field {
- field = Field::Text(TextField::SiteWithout);
- tv_field = schema.get_field(field.name()).unwrap();
- }
-
return Self {
patterns: Vec::new(),
field: tv_field,
@@ -224,7 +219,7 @@ impl FastSiteDomainPatternWeight {
let fieldnorm_reader = self.fieldnorm_reader(reader)?;
let field_no_tokenizer = match ALL_FIELDS[self.field.field_id() as usize] {
- Field::Text(TextField::SiteWithout) => Field::Text(TextField::SiteNoTokenizer),
+ Field::Text(TextField::UrlForSiteOperator) => Field::Text(TextField::SiteNoTokenizer),
Field::Text(TextField::Domain) => Field::Text(TextField::DomainNoTokenizer),
_ => unreachable!(),
};
diff --git a/core/src/ranking/inbound_similarity.rs b/core/src/ranking/inbound_similarity.rs
index 020e7313..ce05bd0e 100644
--- a/core/src/ranking/inbound_similarity.rs
+++ b/core/src/ranking/inbound_similarity.rs
@@ -53,6 +53,7 @@ struct NodeScorer {
inbound: bitvec_similarity::BitVec,
precalculated: Arc<PreCalculatedSimilarities>,
self_score: f64,
+ default_if_precalculated: bool,
}
impl NodeScorer {
@@ -66,6 +67,7 @@ impl NodeScorer {
inbound,
precalculated,
self_score: 1.0,
+ default_if_precalculated: false,
}
}
@@ -73,9 +75,21 @@ impl NodeScorer {
self.self_score = self_score;
}
+ fn set_default_if_precalculated(&mut self, default_if_precalculated: bool) {
+ self.default_if_precalculated = default_if_precalculated;
+ }
+
fn sim(&self, other: &NodeID, other_inbound: &bitvec_similarity::BitVec) -> f64 {
if self.node == *other {
self.self_score
+ } else if self.default_if_precalculated {
+ self.precalculated
+ .get_or_default_if_precalculated(&self.node, other)
+ .or_else(|| {
+ self.precalculated
+ .get_or_default_if_precalculated(other, &self.node)
+ })
+ .unwrap_or_else(|| self.inbound.sim(other_inbound))
} else {
self.precalculated
.get(&self.node, other)
@@ -130,6 +144,24 @@ impl Scorer {
scorer.set_self_score(self_score);
}
}
+
+ /// Speedups calculation when we encounter a node for which we have
+ /// precalculated similarities. This means, the chosen node is a node
+ /// with many inbound links. If we encounter another node for which
+ /// we have no precalcalculated similarities with the chosen node, they
+ /// are most likely not very similar, so we can just assume a similarity
+ /// of 0.0.
+ ///
+ /// Needless to say, this is less accurate than calculating the similarity.
+ pub fn set_default_if_precalculated(&mut self, default_if_precalculated: bool) {
+ for scorer in self.liked.iter_mut() {
+ scorer.set_default_if_precalculated(default_if_precalculated);
+ }
+
+ for scorer in self.disliked.iter_mut() {
+ scorer.set_default_if_precalculated(default_if_precalculated);
+ }
+ }
}
#[derive(Serialize, Deserialize, Default)]
@@ -138,6 +170,10 @@ struct PreCalculatedSimilarities {
}
impl PreCalculatedSimilarities {
+ fn get_or_default_if_precalculated(&self, node: &NodeID, other: &NodeID) -> Option<f64> {
+ Some(self.map.get(node)?.get(other).copied().unwrap_or_default())
+ }
+
fn get(&self, node: &NodeID, other: &NodeID) -> Option<f64> {
self.map.get(node)?.get(other).copied()
}
diff --git a/core/src/ranking/signal.rs b/core/src/ranking/signal.rs
index c769a502..791d7f7b 100644
--- a/core/src/ranking/signal.rs
+++ b/core/src/ranking/signal.rs
@@ -924,6 +924,9 @@ impl SignalAggregator {
}
pub fn set_inbound_similarity(&mut self, scorer: inbound_similarity::Scorer) {
+ let mut scorer = scorer;
+ scorer.set_default_if_precalculated(true);
+
self.inbound_similarity = Some(RefCell::new(scorer));
}
diff --git a/core/src/search_prettifier/stack_overflow.rs b/core/src/search_prettifier/stack_overflow.rs
index da9e59f0..d5106209 100644
--- a/core/src/search_prettifier/stack_overflow.rs
+++ b/core/src/search_prettifier/stack_overflow.rs
@@ -50,6 +50,22 @@ pub enum CodeOrText {
Text(String),
}
+fn parse_code(item: schema_org::Item) -> Option<CodeOrText> {
+ let s = item
+ .properties
+ .get("text")
+ .and_then(|p| p.clone().one())
+ .and_then(|prop| prop.try_into_string())
+ .unwrap_or_default()
+ .to_string();
+
+ if s.is_empty() {
+ return None;
+ }
+
+ Some(CodeOrText::Code(s))
+}
+
fn parse_so_answer(
text: OneOrMany<Property>,
date: OneOrMany<Property>,
@@ -63,15 +79,7 @@ fn parse_so_answer(
.into_iter()
.map(|prop| match prop {
Property::String(s) => CodeOrText::Text(s),
- Property::Item(item) => CodeOrText::Code(
- item.properties
- .get("text")
- .and_then(|p| p.clone().one())
- .and_then(|prop| prop.try_into_string())
- .unwrap_or_default()
- .trim()
- .to_string(),
- ),
+ Property::Item(item) => parse_code(item).unwrap(),
})
.collect();
@@ -148,8 +156,9 @@ fn limit_chars(passages: &[CodeOrText], limit: usize) -> Vec<CodeOrText> {
}
pub fn stackoverflow_snippet(webpage: &RetrievedWebpage) -> Result<Snippet> {
- match webpage
- .schema_org
+ let schema_org = &webpage.schema_org;
+
+ match schema_org
.iter()
.find(|item| item.types_contains("QAPage"))
.and_then(|item| item.properties.get("mainEntity"))
@@ -165,13 +174,7 @@ pub fn stackoverflow_snippet(webpage: &RetrievedWebpage) -> Result<Snippet> {
.into_iter()
.map(|prop| match prop {
Property::String(s) => CodeOrText::Text(s),
- Property::Item(item) => CodeOrText::Code(
- item.properties
- .get("text")
- .and_then(|p| p.clone().one())
- .and_then(|prop| prop.try_into_string())
- .unwrap_or_default(),
- ),
+ Property::Item(item) => parse_code(item).unwrap(),
})
.collect();
diff --git a/core/src/searcher/local.rs b/core/src/searcher/local.rs
index fade6233..aa36bcf9 100644
--- a/core/src/searcher/local.rs
+++ b/core/src/searcher/local.rs
@@ -33,7 +33,7 @@ use crate::ranking::models::linear::LinearRegression;
use crate::ranking::pipeline::{RankingPipeline, RankingWebsite};
use crate::ranking::{query_centrality, Ranker, Signal, SignalAggregator, ALL_SIGNALS};
use crate::search_ctx::Ctx;
-use crate::search_prettifier::{DisplayedEntity, DisplayedWebpage, HighlightedSpellCorrection};
+use crate::search_prettifier::{DisplayedEntity, DisplayedWebpage};
use crate::webgraph::Node;
use crate::{inverted_index, live_index, Error, Result};
@@ -277,7 +277,6 @@ where
.collect();
let scorer = inbound_sim.scorer(&liked_hosts, &disliked_hosts, false);
-
aggregator.set_inbound_similarity(scorer);
}
@@ -341,8 +340,6 @@ where
let sidebar = self.entity_sidebar(query);
Ok(InitialWebsiteResult {
- // spell_corrected_query: correction,
- spell_corrected_query: None,
websites: inverted_index_result.webpages,
num_websites: inverted_index_result.num_hits,
has_more: inverted_index_result.has_more,
@@ -445,13 +442,11 @@ where
}
Ok(WebsitesResult {
- spell_corrected_query: search_result
- .spell_corrected_query
- .map(HighlightedSpellCorrection::from),
num_hits: search_result.num_websites,
webpages,
discussions: None,
widget: None,
+ spell_corrected_query: None,
direct_answer: None,
sidebar: search_result
.entity_sidebar
diff --git a/core/src/searcher/mod.rs b/core/src/searcher/mod.rs
index 368db14b..5e83236e 100644
--- a/core/src/searcher/mod.rs
+++ b/core/src/searcher/mod.rs
@@ -33,7 +33,6 @@ use crate::{
search_prettifier::{
DisplayedAnswer, DisplayedSidebar, DisplayedWebpage, HighlightedSpellCorrection,
},
- web_spell::Correction,
webpage::region::Region,
widgets::Widget,
};
@@ -76,7 +75,6 @@ pub struct SearchQuery {
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct InitialWebsiteResult {
- pub spell_corrected_query: Option<Correction>,
pub num_websites: Option<usize>,
pub websites: Vec<RankingWebsite>,
pub has_more: bool,
diff --git a/core/src/web_spell/spell_checker.rs b/core/src/web_spell/spell_checker.rs
index ec031054..1ceb86a8 100644
--- a/core/src/web_spell/spell_checker.rs
+++ b/core/src/web_spell/spell_checker.rs
@@ -277,7 +277,12 @@ mod tests {
return;
}
- let spell_checker = SpellChecker::open(path, CorrectionConfig::default()).unwrap();
+ let conf = CorrectionConfig {
+ correction_threshold: 16.0,
+ ..Default::default()
+ };
+
+ let spell_checker = SpellChecker::open(path, conf).unwrap();
assert_eq!(spell_checker.correct("hello", &Lang::Eng), None);
assert_eq!(
diff --git a/core/src/webgraph/store.rs b/core/src/webgraph/store.rs
index bd9711ca..9871cc9b 100644
--- a/core/src/webgraph/store.rs
+++ b/core/src/webgraph/store.rs
@@ -487,11 +487,11 @@ impl EdgeStore {
let edge_labels = &self.edge_labels[edge_range];
let edge_labels = self.compression.decompress(edge_labels);
- let edge_labels: Vec<String> = bincode::deserialize(&edge_labels).unwrap();
+ let edge_labels: Vec<_> = bincode::deserialize(&edge_labels).unwrap();
let edge_nodes = &self.edge_nodes[node_range];
let edge_nodes = self.compression.decompress(edge_nodes);
- let edge_nodes: Vec<NodeID> = bincode::deserialize(&edge_nodes).unwrap();
+ let edge_nodes: Vec<_> = bincode::deserialize(&edge_nodes).unwrap();
edge_labels
.into_iter()
@@ -528,7 +528,7 @@ impl EdgeStore {
let edge_nodes = &self.edge_nodes[node_range];
let edge_nodes = self.compression.decompress(edge_nodes);
- let edge_nodes: Vec<NodeID> = bincode::deserialize(&edge_nodes).unwrap();
+ let edge_nodes: Vec<_> = bincode::deserialize(&edge_nodes).unwrap();
edge_nodes
.into_iter()
@@ -571,7 +571,7 @@ impl EdgeStore {
let node_range = bincode::deserialize::<Range<usize>>(&val).unwrap();
let edge_nodes = &self.edge_nodes[node_range];
let edge_nodes = self.compression.decompress(edge_nodes);
- let edge_nodes: Vec<NodeID> = bincode::deserialize(&edge_nodes).unwrap();
+ let edge_nodes: Vec<_> = bincode::deserialize(&edge_nodes).unwrap();
edge_nodes.into_iter().map(move |other| {
if self.reversed {
diff --git a/core/src/webpage/schema_org/microdata.rs b/core/src/webpage/schema_org/microdata.rs
index ae7a4c3d..328a8ca2 100644
--- a/core/src/webpage/schema_org/microdata.rs
+++ b/core/src/webpage/schema_org/microdata.rs
@@ -57,7 +57,7 @@ fn parse_properties(node: NodeRef) -> Vec<RawProperty> {
);
res.push(RawProperty::Item(RawItem {
- itemtype: Some(RawOneOrMany::One("SourceCode".to_string())),
+ itemtype: Some(RawOneOrMany::One("SoftwareSourceCode".to_string())),
properties,
}));
diff --git a/core/src/webpage/schema_org/mod.rs b/core/src/webpage/schema_org/mod.rs
index 036a4aa7..c33f53bb 100644
--- a/core/src/webpage/schema_org/mod.rs
+++ b/core/src/webpage/schema_org/mod.rs
@@ -336,7 +336,7 @@ mod tests {
assert_eq!(
text[1],
RawProperty::Item(RawItem {
- itemtype: Some(RawOneOrMany::One("SourceCode".to_string())),
+ itemtype: Some(RawOneOrMany::One("SoftwareSourceCode".to_string())),
properties: hashmap! {
"text".to_string() => RawOneOrMany::One(RawProperty::String("<p>\n<a href=\"foo\">\n".to_string()))
}
@@ -414,7 +414,7 @@ mod tests {
.unwrap()
.one()
.unwrap(),
- "SourceCode".to_string()
+ "SoftwareSourceCode".to_string()
);
assert!(
parts[1]
diff --git a/core/testcases/schema_org/stackoverflow_inline.html b/core/testcases/schema_org/stackoverflow_inline.html
new file mode 100644
index 00000000..d61956a6
--- /dev/null
+++ b/core/testcases/schema_org/stackoverflow_inline.html
@@ -0,0 +1,2536 @@
+<!DOCTYPE html>
+
+
+ <html itemscope itemtype="https://schema.org/QAPage" class="html__responsive " lang="en">
+
+ <head>
+
+ <title>Javascript Closures and Variable Scope - Stack Overflow</title>
+ <link rel="shortcut icon" href="https://cdn.sstatic.net/Sites/stackoverflow/Img/favicon.ico?v=ec617d715196">
+ <link rel="apple-touch-icon" href="https://cdn.sstatic.net/Sites/stackoverflow/Img/apple-touch-icon.png?v=c78bd457575a">
+ <link rel="image_src" href="https://cdn.sstatic.net/Sites/stackoverflow/Img/apple-touch-icon.png?v=c78bd457575a">
+ <link rel="search" type="application/opensearchdescription+xml" title="Stack Overflow" href="/opensearch.xml">
+ <link rel="canonical" href="https://stackoverflow.com/questions/7015668/javascript-closures-and-variable-scope" />
+ <meta name="viewport" content="width=device-width, height=device-height, initial-scale=1.0, minimum-scale=1.0">
+ <meta property="og:type" content= "website" />
+ <meta property="og:url" content="https://stackoverflow.com/questions/7015668/javascript-closures-and-variable-scope"/>
+ <meta property="og:site_name" content="Stack Overflow" />
+ <meta property="og:image" itemprop="image primaryImageOfPage" content="https://cdn.sstatic.net/Sites/stackoverflow/Img/[email protected]?v=73d79a89bded" />
+ <meta name="twitter:card" content="summary"/>
+ <meta name="twitter:domain" content="stackoverflow.com"/>
+ <meta name="twitter:title" property="og:title" itemprop="name" content="Javascript Closures and Variable Scope" />
+ <meta name="twitter:description" property="og:description" itemprop="description" content="I&#x27;m extending my previous question, because I still don&#x27;t fully understand the concept of javascript closures. Take a quick look at the following code, which will put two markers on a map. (The c..." />
+ <script id="webpack-public-path" type="text/uri-list">https://cdn.sstatic.net/</script>
+ <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
+ <script defer src="https://cdn.sstatic.net/Js/third-party/npm/@stackoverflow/stacks/dist/js/stacks.min.js?v=d5f780ae3281"></script>
+ <script src="https://cdn.sstatic.net/Js/stub.en.js?v=af8bf5a55c16"></script>
+
+ <link rel="stylesheet" type="text/css" href="https://cdn.sstatic.net/Shared/stacks.css?v=5d83236da4e2">
+ <link rel="stylesheet" type="text/css" href="https://cdn.sstatic.net/Sites/stackoverflow/primary.css?v=e555aac91173">
+
+
+
+ <link rel="alternate" type="application/atom+xml" title="Feed for question &#x27;Javascript Closures and Variable Scope&#x27;" href="/feeds/question/7015668">
+ <script>
+ StackExchange.ready(function () {
+
+ StackExchange.using("snippets", function () {
+ StackExchange.snippets.initSnippetRenderer();
+ });
+
+ StackExchange.using("postValidation", function () {
+ StackExchange.postValidation.initOnBlurAndSubmit($('#post-form'), 2, 'answer');
+ });
+
+
+ StackExchange.question.init({showAnswerHelp:true,showTrendingSortLaunchPopover:false,showTrendingSortPostLaunchPopover:false,totalCommentCount:3,shownCommentCount:3,enableTables:true,questionId:7015668});
+
+ styleCode();
+
+ StackExchange.realtime.subscribeToQuestion('1', '7015668');
+ StackExchange.using("gps", function () { StackExchange.gps.trackOutboundClicks('#content', '.js-post-body'); });
+
+
+ });
+ </script>
+
+
+
+
+ <link rel="stylesheet" type="text/css" href="https://cdn.sstatic.net/Shared/Channels/channels.css?v=64256d36becc">
+
+
+
+
+
+ <script type="application/json" data-role="module-args" data-module-name="Shared/options.mod">{"options":{"locale":"en","serverTime":1702565845,"routeName":"Questions/Show","stackAuthUrl":"https://stackauth.com","networkMetaHostname":"meta.stackexchange.com","site":{"name":"Stack Overflow","description":"Q\u0026A for professional and enthusiast programmers","isNoticesTabEnabled":true,"enableNewTagCreationWarning":true,"insertSpaceAfterNameTabCompletion":false,"id":1,"cookieDomain":".stackoverflow.com","childUrl":"https://meta.stackoverflow.com","negativeVoteScoreFloor":null,"enableSocialMediaInSharePopup":true,"protocol":"https"},"user":{"fkey":"103c124eeda5357e9b36b1f9707d5e0e098dc76d7770a150b1317852974be26a","tid":"5c2ab3bd-d9fb-4a67-b3df-1d38b47cc558","rep":0,"isAnonymous":true,"isAnonymousNetworkWide":true,"ab":{"collectives_survey":{"v":"coso_survey","g":2},"satisfaction_survey_anon":{"v":"anon","g":1}}},"events":{"postType":{"question":1},"postEditionSection":{"title":1,"body":2,"tags":3}}}}</script>
+<script type="application/json" data-role="module-args" data-module-name="Shared/settings.mod">{"settings":{"userMessaging":{"showNewFeatureNotice":true},"tags":{},"subscriptions":{"defaultBasicMaxTrueUpSeats":250,"defaultFreemiumMaxTrueUpSeats":50,"defaultMaxTrueUpSeats":1000},"snippets":{"renderDomain":"stacksnippets.net","snippetsEnabled":true},"site":{"allowImageUploads":true,"enableImgurHttps":true,"enableUserHovercards":true,"forceHttpsImages":true,"stacksEditorPreviewEnabled":true,"styleCode":true},"search":{},"questions":{"enableQuestionTitleLengthLiveWarning":true,"enableSavesFeature":true,"maxTitleSize":150,"questionTitleLengthStartLiveWarningChars":50},"intercom":{"appId":"inf0secd","enableJavascriptImplementationFor":true,"hostBaseUrl":"https://stacksnippets.net"},"paths":{"jQueryUICSSPath":"https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.0/themes/smoothness/jquery-ui.css","jQueryUIJSPath":"https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.0/jquery-ui.min.js"},"mentions":{"maxNumUsersInDropdown":50},"markdown":{"enableTables":true},"legal":{"oneTrustConfigId":"c3d9f1e3-55f3-4eba-b268-46cee4c6789c","tCFConsentTestCookieName":"TCFConsentTest","useCustomConsent":true},"flags":{"allowRetractingCommentFlags":true,"allowRetractingFlags":true},"elections":{"opaVoteResultsBaseUrl":"https://www.opavote.com/results/"},"comments":{},"accounts":{"currentPasswordRequiredForChangingStackIdPassword":true}}}</script>
+<script>StackExchange.init();</script>
+
+ <script>
+ StackExchange.using.setCacheBreakers({"Js/adops.en.js":"6da43f5e0a84","Js/ask.en.js":"","Js/begin-edit-event.en.js":"20edbaccceae","Js/copy-transpiled.en.js":"d31dc7eba3bc","Js/events.en.js":"","Js/explore-qlist.en.js":"2b1f34938b8b","Js/full-anon.en.js":"192ecaea0c9d","Js/full.en.js":"efb11489a333","Js/highlightjs-loader.en.js":"510e2f94c2bf","Js/inline-tag-editing.en.js":"3e8cc64ee9d6","Js/keyboard-shortcuts.en.js":"107c2ac31497","Js/markdown-it-loader.en.js":"5818ef89ff9d","Js/mentions-transpiled.en.js":"36b8cabd2c12","Js/moderator.en.js":"0f6d7017d74d","Js/postCollections-transpiled.en.js":"ea1228154a76","Js/post-validation.en.js":"8fd6c83cea6c","Js/question-editor.en.js":"","Js/review-v2-transpiled.en.js":"7b6b513b5808","Js/revisions.en.js":"47b4d5ac24c9","Js/stacks-editor.en.js":"45ddc00eb16e","Js/tageditor.en.js":"dc13482a67f8","Js/tageditornew.en.js":"b11be3ff22c6","Js/tagsuggestions.en.js":"bd6ec908f2a7","Js/unlimited-transpiled.en.js":"f26a1d5f3365","Js/wmd.en.js":"033a0412fcae","Js/snippet-javascript-codemirror.en.js":"ae1dcf38deb7"});
+ StackExchange.using("gps", function() {
+ StackExchange.gps.init(false);
+ });
+ </script>
+ <noscript id="noscript-css"><style>body,.s-topbar{margin-top:1.9em}</style></noscript>
+ </head>
+ <body class="question-page unified-theme">
+ <div id="notify-container"></div>
+ <div id="custom-header"></div>
+
+
+<header class="s-topbar ps-fixed t0 l0 js-top-bar">
+ <div class="s-topbar--container">
+ <a href="#" class="s-topbar--menu-btn js-left-sidebar-toggle" role="menuitem" aria-haspopup="true" aria-controls="left-sidebar" aria-expanded="false"><span></span></a>
+ <div class="topbar-dialog leftnav-dialog js-leftnav-dialog dno">
+ <div class="left-sidebar js-unpinned-left-sidebar" data-can-be="left-sidebar" data-is-here-when="sm"></div>
+ </div>
+ <a href="https://stackoverflow.com" class="s-topbar--logo js-gps-track"
+ data-gps-track="top_nav.click({is_current:false, location:2, destination:8})">
+ <span class="-img _glyph">Stack Overflow</span>
+ </a>
+
+
+
+ <ol class="s-navigation" role="presentation">
+
+ <li class="md:d-none">
+ <a href="https://stackoverflow.co/" class="s-navigation--item js-gps-track"
+ data-gps-track="top_nav.products.click({location:2, destination:7})"
+ data-ga="[&quot;top navigation&quot;,&quot;about menu click&quot;,null,null,null]">About</a>
+ </li>
+
+ <li>
+ <a href="#"
+ class="s-navigation--item js-gps-track js-products-menu"
+ aria-controls="products-popover"
+ data-controller="s-popover"
+ data-action="s-popover#toggle"
+ data-s-popover-placement="bottom"
+ data-s-popover-toggle-class="is-selected"
+ data-gps-track="top_nav.products.click({location:2, destination:1})"
+ data-ga="[&quot;top navigation&quot;,&quot;products menu click&quot;,null,null,null]">
+ Products
+ </a>
+ </li>
+
+ <li class="md:d-none">
+ <a href="https://stackoverflow.co/teams/" class="s-navigation--item js-gps-track"
+ data-gps-track="top_nav.products.click({location:2, destination:7})"
+ data-ga="[&quot;top navigation&quot;,&quot;learn more - teams&quot;,null,null,null]">For Teams</a>
+ </li>
+ </ol>
+ <div class="s-popover ws2 mtn2 p0"
+ id="products-popover"
+ role="menu"
+ aria-hidden="true">
+ <div class="s-popover--arrow"></div>
+ <ol class="list-reset s-anchors s-anchors__inherit">
+ <li class="m6">
+ <a href="/questions" class="bar-sm p6 d-block h:bg-black-225 js-gps-track"
+ data-gps-track="top_nav.products.click({location:2, destination:2})"
+ data-ga="[&quot;top navigation&quot;,&quot;public qa submenu click&quot;,null,null,null]">
+ <span class="fs-body1 d-block">Stack Overflow</span>
+ <span class="fs-caption d-block fc-black-400">Public questions &amp; answers</span>
+ </a>
+ </li>
+ <li class="m6">
+ <a href="https://stackoverflow.co/teams/" class="bar-sm p6 d-block h:bg-black-225 js-gps-track"
+ data-gps-track="top_nav.products.click({location:2, destination:3})"
+ data-ga="[&quot;top navigation&quot;,&quot;teams submenu click&quot;,null,null,null]">
+ <span class="fs-body1 d-block">Stack Overflow for Teams</span>
+ <span class="fs-caption d-block fc-black-400">Where developers &amp; technologists share private knowledge with coworkers</span>
+ </a>
+ </li>
+ <li class="m6">
+ <a href="https://stackoverflow.co/talent/" class="bar-sm p6 d-block h:bg-black-225 js-gps-track"
+ data-gps-track="top_nav.products.click({location:2, destination:5})"
+ data-ga="[&quot;top navigation&quot;,&quot;talent submenu click&quot;,null,null,null]">
+ <span class="fs-body1 d-block">Talent</span>
+ <span class="fs-caption d-block fc-black-400">
+ Build your employer brand
+ </span>
+ </a>
+ </li>
+ <li class="m6">
+ <a href="https://stackoverflow.co/advertising/" class="bar-sm p6 d-block h:bg-black-225 js-gps-track"
+ data-gps-track="top_nav.products.click({location:2, destination:6})"
+ data-ga="[&quot;top navigation&quot;,&quot;advertising submenu click&quot;,null,null,null]">
+ <span class="fs-body1 d-block">Advertising</span>
+ <span class="fs-caption d-block fc-black-400">Reach developers &amp; technologists worldwide</span>
+ </a>
+ </li>
+ <li class="bt bc-black-200 py6 px6 bbr-md">
+ <a href="https://stackoverflow.co/labs/" class="bar-sm p6 d-block h:bg-black-225 js-gps-track"
+ data-gps-track="top_nav.products.click({location:2, destination:7})"
+ data-ga="[&quot;top navigation&quot;,&quot;labs submenu click&quot;,null,null,null]">
+ <span class="fs-body1 d-block">Labs</span>
+ <span class="fs-caption d-block fc-black-400">The future of collective knowledge sharing</span>
+ </a>
+ </li>
+ <li class="bg-black-100 bt bc-black-200 py6 px6 bbr-md">
+ <a href="https://stackoverflow.co/" class="fc-black-400 d-block py6 px6 h:fc-black-600 js-gps-track"
+ data-gps-track="top_nav.products.click({location:2, destination:7})"
+ data-ga="[&quot;top navigation&quot;,&quot;about submenu click&quot;,null,null,null]">About the company</a>
+ </li>
+ </ol>
+ </div>
+
+
+ <form id="search" role="search" action=/search class="s-topbar--searchbar js-searchbar " autocomplete="off">
+ <div class="s-topbar--searchbar--input-group">
+ <input name="q"
+ type="text"
+ role="combobox"
+ placeholder="Search&#x2026;"
+ value=""
+ autocomplete="off"
+ maxlength="240"
+ class="s-input s-input__search js-search-field "
+ aria-label="Search"
+ aria-controls="top-search"
+ data-controller="s-popover"
+ data-action="focus->s-popover#show"
+ data-s-popover-placement="bottom-start" />
+ <svg aria-hidden="true" class="s-input-icon s-input-icon__search svg-icon iconSearch" width="18" height="18" viewBox="0 0 18 18"><path d="m18 16.5-5.14-5.18h-.35a7 7 0 1 0-1.19 1.19v.35L16.5 18l1.5-1.5ZM12 7A5 5 0 1 1 2 7a5 5 0 0 1 10 0Z"/></svg>
+ <div class="s-popover p0 wmx100 wmn4 sm:wmn-initial js-top-search-popover" id="top-search" role="menu">
+ <div class="s-popover--arrow"></div>
+ <div class="js-spinner p24 d-flex ai-center jc-center d-none">
+ <div class="s-spinner s-spinner__sm fc-orange-400">
+ <div class="v-visible-sr">Loading&#x2026;</div>
+ </div>
+ </div>
+
+ <span class="v-visible-sr js-screen-reader-info"></span>
+ <div class="js-ac-results overflow-y-auto hmx3 d-none"></div>
+
+ <div class="js-search-hints" aria-describedby="Tips for searching"></div>
+</div>
+ </div>
+ </form>
+
+<nav class="h100 ml-auto overflow-x-auto pr12">
+ <ol class="s-topbar--content" role="menubar">
+
+
+
+ <li class="js-topbar-dialog-corral" role="presentation">
+
+
+ <div class="topbar-dialog siteSwitcher-dialog dno" role="menu">
+ <div class="header fw-wrap">
+ <h3 class="flex--item">
+ <a href="https://stackoverflow.com">current community</a>
+ </h3>
+ <div class="flex--item fl1">
+ <div class="ai-center d-flex jc-end">
+ <button
+ class="js-close-button s-btn s-btn__muted p0 ml8 d-none sm:d-block"
+ type="button"
+ aria-label="Close"
+ >
+ <svg aria-hidden="true" class="svg-icon iconClear" width="18" height="18" viewBox="0 0 18 18"><path d="M15 4.41 13.59 3 9 7.59 4.41 3 3 4.41 7.59 9 3 13.59 4.41 15 9 10.41 13.59 15 15 13.59 10.41 9 15 4.41Z"/></svg>
+ </button>
+ </div>
+ </div>
+ </div>
+ <div class="modal-content bg-blue-200 current-site-container">
+ <ul class="current-site ">
+ <li class="d-flex">
+ <div class="fl1">
+ <a href="https://stackoverflow.com"
+ class="current-site-link site-link js-gps-track d-flex gs8 gsx"
+ data-id="1"
+ data-gps-track="site_switcher.click({ item_type:3 })">
+ <div class="favicon favicon-stackoverflow site-icon flex--item" title="Stack Overflow"></div>
+ <span class="flex--item fl1">
+ Stack Overflow
+ </span>
+ </a>
+
+ </div>
+ <div class="related-links">
+ <a href="https://stackoverflow.com/help" class="js-gps-track" data-gps-track="site_switcher.click({ item_type:14 })">help</a>
+ <a href="https://chat.stackoverflow.com/?tab=site&amp;host=stackoverflow.com" class="js-gps-track" data-gps-track="site_switcher.click({ item_type:6 })">chat</a>
+ </div>
+
+ </li>
+ <li class="related-site d-flex">
+ <div class="L-shaped-icon-container">
+ <span class="L-shaped-icon"></span>
+ </div>
+
+ <a href="https://meta.stackoverflow.com"
+ class=" site-link js-gps-track d-flex gs8 gsx"
+ data-id="552"
+ data-gps-track="site.switch({ target_site:552, item_type:3 }),site_switcher.click({ item_type:4 })">
+ <div class="favicon favicon-stackoverflowmeta site-icon flex--item" title="Meta Stack Overflow"></div>
+ <span class="flex--item fl1">
+ Meta Stack Overflow
+ </span>
+ </a>
+
+ </li>
+ </ul>
+ </div>
+
+ <div class="header" id="your-communities-header">
+ <h3>
+your communities </h3>
+
+ </div>
+ <div class="modal-content" id="your-communities-section">
+
+ <div class="call-to-login">
+<a href="https://stackoverflow.com/users/signup?ssrc=site_switcher&amp;returnurl=https%3a%2f%2fstackoverflow.com%2fquestions%2f7015668%2fjavascript-closures-and-variable-scope%2f7015823" class="login-link js-gps-track" data-gps-track="site_switcher.click({ item_type:10 })">Sign up</a> or <a href="https://stackoverflow.com/users/login?ssrc=site_switcher&amp;returnurl=https%3a%2f%2fstackoverflow.com%2fquestions%2f7015668%2fjavascript-closures-and-variable-scope%2f7015823" class="login-link js-gps-track" data-gps-track="site_switcher.click({ item_type:11 })">log in</a> to customize your list. </div>
+ </div>
+
+ <div class="header">
+ <h3><a href="https://stackexchange.com/sites">more stack exchange communities</a>
+ </h3>
+ <a href="https://stackoverflow.blog" class="float-right">company blog</a>
+ </div>
+ <div class="modal-content">
+ <div class="child-content"></div>
+ </div>
+ </div>
+
+ </li>
+
+ <li role="none"><button class="s-topbar--item s-btn s-btn__icon s-btn__muted d-none sm:d-inline-flex js-searchbar-trigger" role="menuitem" aria-label="Search" aria-haspopup="true" aria-controls="search" title="Click to show search"><svg aria-hidden="true" class="svg-icon iconSearch" width="18" height="18" viewBox="0 0 18 18"><path d="m18 16.5-5.14-5.18h-.35a7 7 0 1 0-1.19 1.19v.35L16.5 18l1.5-1.5ZM12 7A5 5 0 1 1 2 7a5 5 0 0 1 10 0Z"/></svg></button></li>
+ <li role="none">
+ <a href="https://stackoverflow.com/users/login?ssrc=head&returnurl=https%3a%2f%2fstackoverflow.com%2fquestions%2f7015668%2fjavascript-closures-and-variable-scope%2f7015823" class="s-topbar--item s-topbar--item__unset s-btn s-btn__outlined ws-nowrap js-gps-track" role="menuitem" rel="nofollow"
+ data-gps-track="login.click" data-ga="[&quot;top navigation&quot;,&quot;login button click&quot;,null,null,null]">Log in</a>
+ </li>
+ <li role="none"><a href="https://stackoverflow.com/users/signup?ssrc=head&returnurl=https%3a%2f%2fstackoverflow.com%2fquestions%2f7015668%2fjavascript-closures-and-variable-scope%2f7015823" class="s-topbar--item s-topbar--item__unset ml4 s-btn s-btn__filled ws-nowrap" role="menuitem" rel="nofollow" data-ga="[&quot;sign up&quot;,&quot;Sign Up Navigation&quot;,&quot;Header&quot;,null,null]">Sign up</a></li>
+ </ol>
+</nav>
+
+
+ </div>
+</header>
+
+ <script>
+ StackExchange.ready(function () { StackExchange.topbar.init(); });
+ StackExchange.scrollPadding.setPaddingTop(50, 10);
+ </script>
+
+
+
+
+
+
+
+<div class="bg-black-100 bs-sm bt bc-black-225 ps-fixed l0 r0 b0 z-nav js-dismissable-hero" data-campaign-name="stk">
+ <div class="d-flex wmx12 mx-auto px8 py12 jc-space-between ai-center lg:pl24 lg:pr24 md:fd-column sm:fd-row sm:ai-center">
+ <div class="flex--item fs-body2 fl1 mr16 md:mr0 md:mb12 sm:mb0 sm:mr16">
+ <p class="mb0"><strong>Join Stack Overflow</strong> to find the best answer to your technical question, help others answer theirs.</p>
+ </div>
+
+ <div id="openid-buttons" class="d-flex gs8 gsx ai-center sm:jc-space-between">
+ <a class="flex--item s-btn s-btn__filled ws-nowrap" href="/users/signup?ssrc=hero&returnurl=https%3a%2f%2fstackoverflow.com%2fquestions%2f7015668%2fjavascript-closures-and-variable-scope%2f7015823" rel="nofollow" data-ga="[&quot;sign up&quot;,&quot;Sign Up Navigation&quot;,&quot;Question Hero&quot;,null,null]">
+ <span class="sm:d-none">Sign up with email</span>
+ <span class="d-none sm:d-inline">Sign up</span>
+
+ </a>
+ <button class="flex--item ws-nowrap s-btn s-btn__icon s-btn__google ta-center js-major-provider sm:d-none" data-provider='google' data-oauthserver='https://accounts.google.com/o/oauth2/auth' data-oauthversion='2.0' data-ga="[&quot;sign up&quot;,&quot;Sign Up Started - Google&quot;,&quot;Question Hero&quot;,null,null]">
+ <svg aria-hidden="true" class="native svg-icon iconGoogle" width="18" height="18" viewBox="0 0 18 18"><path fill="#4285F4" d="M16.51 8H8.98v3h4.3c-.18 1-.74 1.48-1.6 2.04v2.01h2.6a7.8 7.8 0 0 0 2.38-5.88c0-.57-.05-.66-.15-1.18Z"/><path fill="#34A853" d="M8.98 17c2.16 0 3.97-.72 5.3-1.94l-2.6-2a4.8 4.8 0 0 1-7.18-2.54H1.83v2.07A8 8 0 0 0 8.98 17Z"/><path fill="#FBBC05" d="M4.5 10.52a4.8 4.8 0 0 1 0-3.04V5.41H1.83a8 8 0 0 0 0 7.18l2.67-2.07Z"/><path fill="#EA4335" d="M8.98 4.18c1.17 0 2.23.4 3.06 1.2l2.3-2.3A8 8 0 0 0 1.83 5.4L4.5 7.49a4.77 4.77 0 0 1 4.48-3.3Z"/></svg>
+ Sign up with Google
+ </button>
+ <button class="flex--item ws-nowrap s-btn s-btn__icon s-btn__github ta-center js-major-provider sm:d-none" data-provider='github' data-oauthserver='https://github.com/login/oauth/authorize' data-oauthversion='2.0' data-ga="[&quot;sign up&quot;,&quot;Sign Up Started - GitHub&quot;,&quot;Question Hero&quot;,null,null]">
+ <svg aria-hidden="true" class="svg-icon iconGitHub" width="18" height="18" viewBox="0 0 18 18"><path fill="#010101" d="M9 1a8 8 0 0 0-2.53 15.59c.4.07.55-.17.55-.38l-.01-1.49c-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82a7.42 7.42 0 0 1 4 0c1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48l-.01 2.2c0 .21.15.46.55.38A8.01 8.01 0 0 0 9 1Z"/></svg>
+ Sign up with GitHub
+ </button>
+ <button class="flex--item ws-nowrap s-btn s-btn__icon s-btn__facebook ta-center js-major-provider sm:d-none" data-provider='facebook' data-oauthserver='https://www.facebook.com/v2.0/dialog/oauth' data-oauthversion='2.0' data-ga="[&quot;sign up&quot;,&quot;Sign Up Started - Facebook&quot;,&quot;Question Hero&quot;,null,null]">
+ <svg aria-hidden="true" class="svg-icon iconFacebook" width="18" height="18" viewBox="0 0 18 18"><path fill="#4167B2" d="M3 1a2 2 0 0 0-2 2v12c0 1.1.9 2 2 2h12a2 2 0 0 0 2-2V3a2 2 0 0 0-2-2H3Zm6.55 16v-6.2H7.46V8.4h2.09V6.61c0-2.07 1.26-3.2 3.1-3.2.88 0 1.64.07 1.87.1v2.16h-1.29c-1 0-1.19.48-1.19 1.18V8.4h2.39l-.31 2.42h-2.08V17h-2.5Z"/></svg>
+ Sign up with Facebook
+ </button>
+ <button class="flex--item s-btn s-btn__muted s-btn__icon px8 js-dismiss" title="Dismiss"><svg aria-hidden="true" class="svg-icon iconClear" width="18" height="18" viewBox="0 0 18 18"><path d="M15 4.41 13.59 3 9 7.59 4.41 3 3 4.41 7.59 9 3 13.59 4.41 15 9 10.41 13.59 15 15 13.59 10.41 9 15 4.41Z"/></svg></button>
+ </div>
+
+ <form id="login-form" action="/users/signup?ssrc=hero&returnurl=https%3a%2f%2fstackoverflow.com%2fquestions%2f7015668%2fjavascript-closures-and-variable-scope%2f7015823" method="POST">
+
+ <input type="hidden" name="fkey" value="103c124eeda5357e9b36b1f9707d5e0e098dc76d7770a150b1317852974be26a">
+
+ <input type="hidden" name="ssrc" value="" />
+
+ <input type="hidden" id="oauth_version" name="oauth_version" />
+ <input type="hidden" id="oauth_server" name="oauth_server" />
+
+ <div id="se-login-fields">
+ <input type="hidden" name="legalLinksShown" value="0" />
+ </div>
+ </form>
+ <script>
+ StackExchange.ready(function () {
+ StackExchange.InlineAuth.init();
+ })
+ </script>
+ </div>
+</div>
+
+<script>
+ StackExchange.ready(function () {
+ StackExchange.Hero.init("stk", "a");
+
+ var location = 0;
+ if ($("body").hasClass("questions-page")) {
+ location = 1;
+ } else if ($("body").hasClass("question-page")) {
+ location = 1;
+ } else if ($("body").hasClass("faq-page")) {
+ location = 5;
+ } else if ($("body").hasClass("home-page")) {
+ location = 3;
+ }
+
+ $('.js-cta-button').click(function () {
+ StackExchange.using("gps", function () {
+ StackExchange.gps.track("hero.action", { hero_action_type: 'cta', location: location }, true);
+ });
+ });
+
+ // TODO: we should review the class names and whatnot in use here. Older heroes use id selectors, the newer
+ // sticky question hero on SO has a .js-dismiss class instead, but it's apparently not used anywhere...
+ // It's not great. Ideally we'd have a set of classes in the partials above that would correspond to
+ // the behaviours we want here in a more clear way.
+
+ // sticky question-page hero at the bottom of the page on SO
+ $('.js-dismiss').on('click', function () {
+ StackExchange.using("gps", function () {
+ StackExchange.gps.track("hero.action", { hero_action_type: "close", location: location }, true);
+ });
+ StackExchange.Hero.dismiss();
+ $(".js-dismissable-hero").fadeOut("fast");
+ });
+ });
+</script>
+
+
+
+ <div class="container">
+
+
+<div id="left-sidebar" data-is-here-when="md lg" class="left-sidebar js-pinned-left-sidebar ps-relative">
+ <div class="left-sidebar--sticky-container js-sticky-leftnav">
+ <nav role="navigation">
+ <ol class="nav-links">
+ <li>
+ <ol class="nav-links">
+
+
+<li class="ps-relative" aria-current="false">
+
+
+ <a
+ href="/"
+ class="pl8 js-gps-track nav-links--link -link__with-icon"
+
+ data-gps-track="top_nav.click({is_current: false, location:2, destination:8, has_activity_notification:False})"
+ aria-controls="" data-controller="" data-s-popover-placement="right"
+ aria-current="false"
+ data-s-popover-auto-show="true" data-s-popover-hide-on-outside-click="never"
+ >
+<svg aria-hidden="true" class="svg-icon iconHome" width="18" height="18" viewBox="0 0 18 18"><path d="M15 10v5a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-5H0l9-9 9 9h-3Zm-8 1v6h4v-6H7Z"/></svg> <span class="-link--channel-name pl6">Home</span>
+ </a>
+</li>
+
+
+
+
+<li class="ps-relative youarehere" aria-current="true">
+
+
+ <a id="nav-questions"
+ href="/questions"
+ class="pl8 js-gps-track nav-links--link -link__with-icon"
+
+ data-gps-track="top_nav.click({is_current: true, location:2, destination:1, has_activity_notification:False})"
+ aria-controls="" data-controller="" data-s-popover-placement="right"
+ aria-current="false"
+ data-s-popover-auto-show="true" data-s-popover-hide-on-outside-click="never"
+ >
+<svg aria-hidden="true" class="svg-icon iconQuestion" width="18" height="18" viewBox="0 0 18 18"><path d="m4 15-3 3V4c0-1.1.9-2 2-2h12c1.09 0 2 .91 2 2v9c0 1.09-.91 2-2 2H4Zm7.75-3.97c.72-.83.98-1.86.98-2.94 0-1.65-.7-3.22-2.3-3.83a4.41 4.41 0 0 0-3.02 0 3.8 3.8 0 0 0-2.32 3.83c0 1.29.35 2.29 1.03 3a3.8 3.8 0 0 0 2.85 1.07c.62 0 1.2-.11 1.71-.34.65.44 1 .68 1.06.7.23.13.46.23.7.3l.59-1.13a5.2 5.2 0 0 1-1.28-.66Zm-1.27-.9a5.4 5.4 0 0 0-1.5-.8l-.45.9c.33.12.66.29.98.5-.2.07-.42.11-.65.11-.61 0-1.12-.23-1.52-.68-.86-1-.86-3.12 0-4.11.8-.9 2.35-.9 3.15 0 .9 1.01.86 3.03-.01 4.08Z"/></svg> <span class="-link--channel-name pl6">Questions</span>
+ </a>
+</li>
+
+
+
+
+
+
+<li class="ps-relative" aria-current="false">
+
+
+ <a
+ href="/tags"
+ class="pl8 js-gps-track nav-links--link -link__with-icon"
+
+ data-gps-track="top_nav.click({is_current: false, location:2, destination:2, has_activity_notification:False})"
+ aria-controls="" data-controller="" data-s-popover-placement="right"
+ aria-current="false"
+ data-s-popover-auto-show="true" data-s-popover-hide-on-outside-click="never"
+ >
+<svg aria-hidden="true" class="svg-icon iconTags" width="18" height="18" viewBox="0 0 18 18"><path d="M9.24 1a3 3 0 0 0-2.12.88l-5.7 5.7a2 2 0 0 0-.38 2.31 3 3 0 0 1 .67-1.01l6-6A3 3 0 0 1 9.83 2H14a3 3 0 0 1 .79.1A2 2 0 0 0 13 1H9.24Z" opacity=".4"/><path d="M9.83 3a2 2 0 0 0-1.42.59l-6 6a2 2 0 0 0 0 2.82L6.6 16.6a2 2 0 0 0 2.82 0l6-6A2 2 0 0 0 16 9.17V5a2 2 0 0 0-2-2H9.83ZM12 9a2 2 0 1 1 0-4 2 2 0 0 1 0 4Z"/></svg> <span class="-link--channel-name pl6">Tags</span>
+ </a>
+</li>
+
+
+ <li class="pb24"></li>
+
+
+
+
+<li class="ps-relative" aria-current="false">
+
+
+ <a id="nav-users"
+ href="/users"
+ class="pl8 js-gps-track nav-links--link -link__with-icon"
+
+ data-gps-track="top_nav.click({is_current: false, location:2, destination:3, has_activity_notification:False})"
+ aria-controls="" data-controller="" data-s-popover-placement="right"
+ aria-current="false"
+ data-s-popover-auto-show="true" data-s-popover-hide-on-outside-click="never"
+ >
+<svg aria-hidden="true" class="svg-icon iconPeople" width="18" height="18" viewBox="0 0 18 18"><path d="M17 14c0 .44-.45 1-1 1H9a1 1 0 0 1-1-1H2c-.54 0-1-.56-1-1 0-2.63 3-4 3-4s.23-.4 0-1c-.84-.62-1.06-.59-1-3 .06-2.42 1.37-3 2.5-3s2.44.58 2.5 3c.06 2.41-.16 2.38-1 3-.23.59 0 1 0 1s1.55.71 2.42 2.09c.78-.72 1.58-1.1 1.58-1.1s.23-.4 0-1c-.84-.61-1.06-.58-1-3 .06-2.41 1.37-3 2.5-3s2.44.59 2.5 3c.05 2.42-.16 2.39-1 3-.23.6 0 1 0 1s3 1.38 3 4Z"/></svg> <span class="-link--channel-name pl6">Users</span>
+ </a>
+</li>
+
+
+
+
+<li class="ps-relative" aria-current="false">
+
+
+ <a id="nav-companies"
+ href="https://stackoverflow.com/jobs/companies?so_medium=stackoverflow&amp;so_source=SiteNav"
+ class="pl8 js-gps-track nav-links--link -link__with-icon"
+
+ data-gps-track="top_nav.click({is_current: false, location:2, destination:12, has_activity_notification:False})"
+ aria-controls="" data-controller="" data-s-popover-placement="right"
+ aria-current="false"
+ data-s-popover-auto-show="true" data-s-popover-hide-on-outside-click="never"
+ >
+<svg aria-hidden="true" class="svg-icon iconBriefcase" width="18" height="18" viewBox="0 0 18 18"><path d="M5 4a1 1 0 0 1 1-1h6a1 1 0 0 1 1 1v1h1a2 2 0 0 1 2 2v6a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V7c0-1.1.9-2 2-2h1V4Zm7 0H6v1h6V4Z"/></svg> <span class="-link--channel-name pl6">Companies</span>
+ </a>
+</li>
+
+
+
+ <li class="ml8 mt32 mb8">
+ <div class="d-flex jc-space-between ai-center">
+ <a
+ class="s-link d-flex fl-grow1 fc-black-400 h:fc-black-600 fs-fine js-collectives-navcta-toggle"
+ href="javascript:void(0)"
+ role="button"
+ aria-controls="popover-discover-collectives"
+ data-controller="s-popover"
+ data-action="s-popover#toggle"
+ data-s-popover-placement="top"
+ data-s-popover-toggle-class="is-selected"
+ data-gps-track="top_nav.click({is_current:false, location:2, destination:17})"
+ >
+ <div class="flex--item fl-grow1 tt-uppercase fc-black-600 fw-bold">Collectives</div>
+ <div class="flex--item px12">
+<svg aria-hidden="true" class="svg-icon iconPlusSm" width="14" height="14" viewBox="0 0 14 14"><path d="M8 2H6v4H2v2h4v4h2V8h4V6H8V2Z"/></svg> </div>
+ </a>
+
+ </div>
+
+ </li>
+
+
+<li class="ps-relative" aria-current="false">
+
+
+ <a id="nav-collective-discover"
+ href="/collectives"
+ class="pl8 ai-center js-collectives-navcta-toggle js-gps-track nav-links--link -link__with-icon"
+
+ data-gps-track="top_nav.click({is_current: false, location:2, destination:18, has_activity_notification:False})"
+ aria-controls="" data-controller="" data-s-popover-placement="right"
+ aria-current="false"
+ data-s-popover-auto-show="true" data-s-popover-hide-on-outside-click="never"
+ >
+<svg aria-hidden="true" class="mt-auto fc-orange-400 svg-icon iconStarVerified" width="18" height="18" viewBox="0 0 18 18"><path d="M9.86.89a1.14 1.14 0 0 0-1.72 0l-.5.58c-.3.35-.79.48-1.23.33l-.72-.25a1.14 1.14 0 0 0-1.49.85l-.14.76c-.1.45-.45.8-.9.9l-.76.14c-.67.14-1.08.83-.85 1.49l.25.72c.15.44.02.92-.33 1.23l-.58.5a1.14 1.14 0 0 0 0 1.72l.58.5c.35.3.48.79.33 1.23l-.25.72c-.23.66.18 1.35.85 1.49l.76.14c.45.1.8.45.9.9l.14.76c.14.67.83 1.08 1.49.85l.72-.25c.44-.15.92-.02 1.23.33l.5.58c.46.52 1.26.52 1.72 0l.5-.58c.3-.35.79-.48 1.23-.33l.72.25c.66.23 1.35-.18 1.49-.85l.14-.76c.1-.45.45-.8.9-.9l.76-.14c.67-.14 1.08-.83.85-1.49l-.25-.72c-.15-.44-.02-.92.33-1.23l.58-.5c.52-.46.52-1.26 0-1.72l-.58-.5c-.35-.3-.48-.79-.33-1.23l.25-.72a1.14 1.14 0 0 0-.85-1.49l-.76-.14c-.45-.1-.8-.45-.9-.9l-.14-.76a1.14 1.14 0 0 0-1.49-.85l-.72.25c-.44.15-.92.02-1.23-.33l-.5-.58Zm-.49 2.67L10.6 6.6c.05.15.19.24.34.25l3.26.22c.36.03.5.48.23.71l-2.5 2.1a.4.4 0 0 0-.14.4l.8 3.16a.4.4 0 0 1-.6.44L9.2 12.13a.4.4 0 0 0-.42 0l-2.77 1.74a.4.4 0 0 1-.6-.44l.8-3.16a.4.4 0 0 0-.13-.4l-2.5-2.1a.4.4 0 0 1 .22-.7l3.26-.23a.4.4 0 0 0 .34-.25l1.22-3.03a.4.4 0 0 1 .74 0Z"/></svg> <span class="-link--channel-name pl6">Explore Collectives</span>
+ </a>
+</li>
+
+
+ <li class="ml8 mt32 mb8">
+ <a href="javascript:void(0)"
+ class="s-link s-link d-flex fl-grow1 fc-black-400 h:fc-black-600 fs-fine"
+ role="button"
+ aria-controls="popover-labs-left-nav"
+ data-controller="s-popover"
+ data-action="s-popover#toggle"
+ data-s-popover-placement="top"
+ data-s-popover-toggle-class="is-selected"
+ >
+ <div class="flex--item fl-grow1 tt-uppercase fc-black-600 fw-bold">Labs</div>
+ <div class="flex--item px12">
+ <svg aria-hidden="true" class="svg-icon iconInfoSm" width="14" height="14" viewBox="0 0 14 14"><path d="M7 1a6 6 0 1 1 0 12A6 6 0 0 1 7 1Zm1 10V6H6v5h2Zm0-6V3H6v2h2Z"/></svg>
+ </div>
+ </a>
+ </li>
+
+
+<li class="ps-relative" aria-current="false">
+
+
+ <a id="nav-labs-discussions"
+ href="/collectives/beta/discussions"
+ class="pl8 ai-center js-gps-track nav-links--link -link__with-icon"
+
+ data-gps-track="top_nav.click({is_current: false, location:2, destination:24, has_activity_notification:False})"
+ aria-controls="" data-controller="" data-s-popover-placement="right"
+ aria-current="false"
+ data-s-popover-auto-show="true" data-s-popover-hide-on-outside-click="never"
+ >
+<svg aria-hidden="true" class="fc-black-400 w16 svg-icon iconSpeechBubble" width="18" height="18" viewBox="0 0 18 18"><path d="m4 15-3 3V4c0-1.1.9-2 2-2h12a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H4Z"/></svg> <span class="-link--channel-name pl6">Discussions</span>
+ </a>
+</li>
+
+ </ol>
+ </li>
+
+
+
+
+
+<li class="js-freemium-cta ps-relative">
+
+ <div class="fs-fine tt-uppercase fc-black-600 fw-bold ml8 mt16 mb8">Teams</div>
+
+ <div class="bt bl bb bc-black-200 p12 pb6 fc-black-500 blr-sm overflow-hidden">
+ <strong class="fc-black-600 mb6">Stack Overflow for Teams</strong>
+ – Start collaborating and sharing organizational knowledge.
+
+ <img class="wmx100 mx-auto my8 h-auto d-block" width="139" height="114" src="https://cdn.sstatic.net/Img/teams/teams-illo-free-sidebar-promo.svg?v=47faa659a05e" alt="">
+
+ <a href="https://try.stackoverflow.co/why-teams/?utm_source=so-owned&amp;utm_medium=side-bar&amp;utm_campaign=campaign-38&amp;utm_content=cta"
+ class="w100 s-btn s-btn__filled s-btn__xs bg-orange-400 js-gps-track"
+ data-gps-track="teams.create.left-sidenav.click({ Action: 6 })"
+ data-ga="[&quot;teams left navigation - anonymous&quot;,&quot;left nav free cta&quot;,&quot;stackoverflow.com/teams/create/free&quot;,null,null]">Create a free Team</a>
+ <a href="https://stackoverflow.co/teams/"
+ class="w100 s-btn s-btn__muted s-btn__xs js-gps-track"
+ data-gps-track="teams.create.left-sidenav.click({ Action: 5 })"
+ data-ga="[&quot;teams left navigation - anonymous&quot;,&quot;left nav free cta&quot;,&quot;stackoverflow.com/teams&quot;,null,null]">Why Teams?</a>
+
+ </div>
+</li>
+
+
+ <li class="d-flex ai-center jc-space-between ml8 mt32 mb8 js-create-team-cta d-none">
+ <a href="javascript:void(0)"
+ class="s-link d-flex fl-grow1 fc-black-400 h:fc-black-600 fs-fine js-gps-track"
+ role="button"
+ aria-controls="popover-teams-create-cta"
+ data-controller="s-popover"
+ data-action="s-popover#toggle"
+ data-s-popover-placement="bottom-start"
+ data-s-popover-toggle-class="is-selected"
+ data-gps-track="teams.create.left-sidenav.click({ Action: ShowInfo })"
+ data-ga="[&quot;teams left navigation - anonymous&quot;,&quot;left nav show teams info&quot;,null,null,null]"
+ >
+ <div class="flex--item fl-grow1 fc-black-600 fw-bold tt-uppercase">Teams</div>
+ <div class="flex--item px12">
+ <svg aria-hidden="true" class="svg-icon iconPlusSm" width="14" height="14" viewBox="0 0 14 14"><path d="M8 2H6v4H2v2h4v4h2V8h4V6H8V2Z"/></svg>
+ </div>
+ </a>
+ </li>
+ <li class="ps-relative js-create-team-cta d-none">
+ <a href="https://stackoverflowteams.com/teams/create/free/?utm_source=so-owned&amp;utm_medium=side-bar&amp;utm_campaign=campaign-38&amp;utm_content=cta"
+ class="pl8 js-gps-track nav-links--link"
+ title="Stack Overflow for Teams is a private, secure spot for your organization's questions and answers."
+ data-gps-track="teams.create.left-sidenav.click({ Action: FreemiumTeamsCreateClick })"
+ data-ga="[&quot;teams left navigation - anonymous&quot;,&quot;left nav team click&quot;,&quot;stackoverflow.com/teams/create/free&quot;,null,null]">
+ <div class="d-flex ai-center">
+ <div class="flex--item s-avatar va-middle bg-orange-400">
+ <div class="s-avatar--letter mtn1">
+ <svg aria-hidden="true" class="svg-icon iconBriefcaseSm" width="14" height="14" viewBox="0 0 14 14"><path d="M4 3a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v1h.5c.83 0 1.5.67 1.5 1.5v5c0 .83-.67 1.5-1.5 1.5h-7A1.5 1.5 0 0 1 2 10.5v-5C2 4.67 2.67 4 3.5 4H4V3Zm5 1V3H5v1h4Z"/></svg>
+ </div>
+ <svg aria-hidden="true" class="native s-avatar--badge svg-icon iconShieldXSm" width="9" height="10" viewBox="0 0 9 10"><path fill="var(--white)" d="M0 1.84 4.5 0 9 1.84v3.17C9 7.53 6.3 10 4.5 10 2.7 10 0 7.53 0 5.01V1.84Z"/><path fill="var(--black-400)" d="M1 2.5 4.5 1 8 2.5v2.51C8 7.34 5.34 9 4.5 9 3.65 9 1 7.34 1 5.01V2.5Zm2.98 3.02L3.2 7h2.6l-.78-1.48a.4.4 0 0 1 .15-.38c.34-.24.73-.7.73-1.14 0-.71-.5-1.23-1.41-1.23-.92 0-1.39.52-1.39 1.23 0 .44.4.9.73 1.14.12.08.18.23.15.38Z"/></svg>
+ </div>
+ <div class="flex--item pl6">
+ Create free Team
+ </div>
+ </div>
+ </a>
+ </li>
+
+ </ol>
+ </nav>
+ </div>
+
+
+ <div class="s-popover ws2" id="popover-discover-collectives" role="menu">
+ <div class="s-popover--arrow"></div>
+ <div>
+ <svg aria-hidden="true" class="fc-orange-400 float-right ml24 svg-spot spotCollective" width="48" height="48" viewBox="0 0 48 48"><path d="M25.5 7a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5ZM14 18.25c0-.69.56-1.25 1.25-1.25h22.5c.69 0 1.25.56 1.25 1.25V37.5a1 1 0 0 1-1.6.8l-4.07-3.05a1.25 1.25 0 0 0-.75-.25H15.25c-.69 0-1.25-.56-1.25-1.25v-15.5ZM7 24.5a2.5 2.5 0 1 1-5 0 2.5 2.5 0 0 1 5 0ZM25.5 48a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5ZM48 24.5a2.5 2.5 0 1 1-5 0 2.5 2.5 0 0 1 5 0Z" opacity=".2"/><path d="M21 3.5a3.5 3.5 0 1 1 7 0 3.5 3.5 0 0 1-7 0ZM24.5 2a1.5 1.5 0 1 0 0 3 1.5 1.5 0 0 0 0-3ZM0 23.5a3.5 3.5 0 1 1 7 0 3.5 3.5 0 0 1-7 0ZM3.5 22a1.5 1.5 0 1 0 0 3 1.5 1.5 0 0 0 0-3ZM21 44.5a3.5 3.5 0 1 1 7 0 3.5 3.5 0 0 1-7 0Zm3.5-1.5a1.5 1.5 0 1 0 0 3 1.5 1.5 0 0 0 0-3Zm20-23a3.5 3.5 0 1 0 0 7 3.5 3.5 0 0 0 0-7ZM43 23.5a1.5 1.5 0 1 1 3 0 1.5 1.5 0 0 1-3 0Zm-23.23-3.14a1 1 0 0 1-.13 1.4l-2.08 1.74 2.08 1.73a1 1 0 1 1-1.28 1.54l-2.42-2.02a1.63 1.63 0 0 1 0-2.5l2.42-2.02a1 1 0 0 1 1.4.13Zm7.59 1.41a1 1 0 1 1 1.28-1.54l2.42 2.02c.78.65.78 1.85 0 2.5l-2.42 2.02a1 1 0 1 1-1.28-1.54l2.08-1.73-2.08-1.73ZM24.12 18a1 1 0 0 1 .87 1.12l-1 8a1 1 0 1 1-1.98-.24l1-8a1 1 0 0 1 1.11-.87Zm-11.87-5C11.01 13 10 14 10 15.25v15.5c0 1.24 1 2.25 2.25 2.25h17.33c.06 0 .11.02.15.05l4.07 3.05a2 2 0 0 0 3.2-1.6V15.25c0-1.24-1-2.25-2.25-2.25h-22.5ZM12 15.25c0-.14.11-.25.25-.25h22.5c.14 0 .25.11.25.25V34.5l-4.07-3.05a2.2 2.2 0 0 0-1.35-.45H12.25a.25.25 0 0 1-.25-.25v-15.5Zm7.24-10.68a1 1 0 1 0-.48-1.94A22.04 22.04 0 0 0 2.91 17.7a1 1 0 1 0 1.92.58 20.04 20.04 0 0 1 14.4-13.72Zm11.05-1.66a1 1 0 0 0-.58 1.92c6.45 1.92 11.54 7 13.46 13.46a1 1 0 1 0 1.92-.58 22.05 22.05 0 0 0-14.8-14.8ZM4.57 28.76a1 1 0 0 0-1.94.48 22.03 22.03 0 0 0 16.13 16.13 1 1 0 1 0 .48-1.94A20.03 20.03 0 0 1 4.57 28.76Zm40.8.48a1 1 0 1 0-1.94-.48 20.04 20.04 0 0 1-13.72 14.41 1 1 0 0 0 .58 1.92 22.04 22.04 0 0 0 15.08-15.85Z"/></svg>
+ <h5 class="pt4 fw-bold">Collectives™ on Stack Overflow</h5>
+ <p class="my16 fs-caption fc-black-500">Find centralized, trusted content and collaborate around the technologies you use most.</p>
+ <a href="/collectives"
+ class="js-gps-track s-btn s-btn__filled s-btn__xs"
+ data-gps-track="top_nav.click({is_current:false, location:2, destination:18})">
+ Learn more about Collectives
+ </a>
+ </div>
+ </div>
+
+ <div class="s-popover ws2"
+ id="popover-teams-create-cta"
+ role="menu"
+ aria-hidden="true">
+ <div class="s-popover--arrow"></div>
+
+ <div class="ps-relative overflow-hidden">
+ <p class="mb2"><strong>Teams</strong></p>
+ <p class="mb12 fs-caption fc-black-400">Q&amp;A for work</p>
+ <p class="mb12 fs-caption fc-black-500">Connect and share knowledge within a single location that is structured and easy to search.</p>
+ <a href="https://stackoverflow.co/teams/"
+ class="js-gps-track s-btn s-btn__filled s-btn__xs"
+ data-gps-track="teams.create.left-sidenav.click({ Action: CtaClick })"
+ data-ga="[&quot;teams left navigation - anonymous&quot;,&quot;left nav cta&quot;,&quot;stackoverflow.com/teams&quot;,null,null]">
+ Learn more about Teams
+ </a>
+ </div>
+
+ <div class="ps-absolute t8 r8">
+ <svg aria-hidden="true" class="fc-orange-400 svg-spot spotPeople" width="48" height="48" viewBox="0 0 48 48"><path d="M13.5 28a4.5 4.5 0 1 0 0-9 4.5 4.5 0 0 0 0 9ZM7 30a1 1 0 0 1 1-1h11a1 1 0 0 1 1 1v5h11v-5a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v10a2 2 0 0 1-2 2H33v5a1 1 0 0 1-1 1H20a1 1 0 0 1-1-1v-5H8a1 1 0 0 1-1-1V30Zm25-6.5a4.5 4.5 0 1 0 9 0 4.5 4.5 0 0 0-9 0ZM24.5 34a4.5 4.5 0 1 0 0-9 4.5 4.5 0 0 0 0 9Z" opacity=".2"/><path d="M16.4 26.08A6 6 0 1 0 7.53 26C5.64 26.06 4 27.52 4 29.45V40a1 1 0 0 0 1 1h9a1 1 0 1 0 0-2h-4v-7a1 1 0 1 0-2 0v7H6v-9.55c0-.73.67-1.45 1.64-1.45H16a1 1 0 0 0 .4-1.92ZM12 18a4 4 0 1 1 0 8 4 4 0 0 1 0-8Zm16.47 14a6 6 0 1 0-8.94 0A3.6 3.6 0 0 0 16 35.5V46a1 1 0 0 0 1 1h14a1 1 0 0 0 1-1V35.5c0-1.94-1.64-3.42-3.53-3.5ZM20 28a4 4 0 1 1 8 0 4 4 0 0 1-8 0Zm-.3 6h8.6c1 0 1.7.75 1.7 1.5V45h-2v-7a1 1 0 1 0-2 0v7h-4v-7a1 1 0 1 0-2 0v7h-2v-9.5c0-.75.7-1.5 1.7-1.5ZM42 22c0 1.54-.58 2.94-1.53 4A3.5 3.5 0 0 1 44 29.45V40a1 1 0 0 1-1 1h-9a1 1 0 1 1 0-2h4v-7a1 1 0 1 1 2 0v7h2v-9.55A1.5 1.5 0 0 0 40.48 28H32a1 1 0 0 1-.4-1.92A6 6 0 1 1 42 22Zm-2 0a4 4 0 1 0-8 0 4 4 0 0 0 8 0Z"/><g opacity=".35"><path d="M17 10a1 1 0 011-1h12a1 1 0 110 2H18a1 1 0 01-1-1Zm1-5a1 1 0 100 2h12a1 1 0 100-2H18ZM14 1a1 1 0 00-1 1v12a1 1 0 001 1h5.09l4.2 4.2a1 1 0 001.46-.04l3.7-4.16H34a1 1 0 001-1V2a1 1 0 00-1-1H14Zm1 12V3h18v10h-5a1 1 0 00-.75.34l-3.3 3.7-3.74-3.75a1 1 0 00-.71-.29H15Z"/></g></svg>
+ </div>
+ </div>
+
+ <div class="s-popover ws2"
+ id="popover-labs-left-nav"
+ role="menu"
+ aria-hidden="true">
+ <div class="s-popover--arrow"></div>
+ <svg aria-hidden="true" class="fc-black-600 mb8 svg-icon iconLabs" width="42" height="18"><path d="M11.5 13.624a.374.374 0 0 1-.37.376H5.361a.374.374 0 0 1-.37-.376V4.376c0-.207.165-.376.37-.376H6.62c.204 0 .37.169.37.376v7.611h4.138c.205 0 .371.169.371.377v1.26zm9.432.215c-.07.1-.185.161-.308.161H19.13a.376.376 0 0 1-.356-.254l-.55-1.7h-3.111l-.55 1.7a.377.377 0 0 1-.355.254h-1.494a.376.376 0 0 1-.353-.506l3.39-9.247A.376.376 0 0 1 16.103 4h1.13c.158 0 .299.099.353.247l3.39 9.247a.376.376 0 0 1-.045.345zm-4.157-7.386l-1.219 3.531h2.266l-1.047-3.53zm13.335 5.71a.37.37 0 0 0-.003.524c.956.971 2.047 1.313 3.486 1.313 1.014 0 1.92-.265 2.582-.788.67-.53 1.063-1.306 1.063-2.255 0-.855-.268-1.622-.867-2.145-.456-.41-1.008-.633-1.89-.767l-1.037-.153c-.377-.057-.672-.19-.832-.332-.146-.132-.221-.315-.221-.568 0-.309.11-.56.306-.737.199-.179.518-.312.986-.312.708 0 1.254.151 1.726.601a.37.37 0 0 0 .516-.004l.883-.87a.37.37 0 0 0-.008-.534C35.942 4.334 35.004 4 33.721 4c-1.016 0-1.872.292-2.479.836-.61.548-.935 1.32-.935 2.207 0 .82.243 1.502.781 2.01h.001c.468.437 1.135.716 1.93.826l1.072.153c.508.073.647.147.795.286l.008.007c.14.125.234.34.234.67 0 .332-.124.567-.344.73-.235.174-.617.293-1.165.293-.867 0-1.49-.185-2.066-.76a.37.37 0 0 0-.522-.003l-.92.908zM22.37 14a.374.374 0 0 1-.37-.376V4.376c0-.207.166-.376.37-.376h3.543c.913 0 1.697.264 2.257.78.564.519.863 1.259.863 2.129 0 .845-.377 1.524-.87 1.947.57.433 1.01 1.145 1.01 2.157 0 .941-.317 1.702-.894 2.224-.57.517-1.354.763-2.225.763H22.37zm3.543-1.977c.96 0 .959-1.01.959-1.01s0-1.013-.959-1.013H24v2.023h1.913zm-.115-4.063c1.074 0 1.074-1.015 1.074-1.015s0-1.016-1.074-1.016H24V7.96h1.798z" fill="var(--black-600)"/><path d="M0 4v10a4 4 0 0 0 4 4h34a4 4 0 0 0 4-4V4a4 4 0 0 0-4-4H4a4 4 0 0 0-4 4zm4-2h34a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2z" fill="var(--black-600)"/></svg>
+ <p class="fs-caption">Get early access and see previews of new features.</p>
+ <a class="s-btn s-btn__filled s-btn__xs s-btn__icon fs-fine" href="https://stackoverflow.co/labs/"><svg aria-hidden="true" class="svg-icon iconShareSm" width="14" height="14" viewBox="0 0 14 14"><path d="M5 1H3a2 2 0 0 0-2 2v8c0 1.1.9 2 2 2h8a2 2 0 0 0 2-2V9h-2v2H3V3h2V1Zm2 0h6v6h-2V4.5L6.5 9 5 7.5 9.5 3H7V1Z"/></svg> Learn more about Labs</a>
+ </div>
+
+
+</div>
+
+
+
+ <div id="content" class="snippet-hidden">
+
+
+
+<div itemprop="mainEntity" itemscope itemtype="https://schema.org/Question">
+ <link itemprop="image" href="https://cdn.sstatic.net/Sites/stackoverflow/Img/apple-touch-icon.png?v=c78bd457575a">
+
+ <div class="inner-content clearfix">
+
+
+
+ <div id="question-header" class="d-flex sm:fd-column">
+ <h1 itemprop="name" class="fs-headline1 ow-break-word mb8 flex--item fl1"><a href="/questions/7015668/javascript-closures-and-variable-scope" class="question-hyperlink">Javascript Closures and Variable Scope</a></h1>
+ <div class="ml12 aside-cta flex--item print:d-none sm:ml0 sm:mb12 sm:order-first sm:as-end">
+ <a href="/questions/ask" class="ws-nowrap s-btn s-btn__filled">
+ Ask Question
+ </a>
+
+ </div>
+ </div>
+ <div class="d-flex fw-wrap pb8 mb16 bb bc-black-200">
+ <div class="flex--item ws-nowrap mr16 mb8" title="2011-08-10 18:12:48Z">
+ <span class="fc-black-400 mr2">Asked</span>
+ <time itemprop="dateCreated" datetime="2011-08-10T18:12:48">12 years, 4 months ago</time>
+ </div>
+ <div class="flex--item ws-nowrap mr16 mb8">
+ <span class="fc-black-400 mr2">Modified</span>
+ <a href="?lastactivity" class="s-link s-link__inherit" title="2011-08-10 18:39:56Z">12 years, 4 months ago</a>
+ </div>
+ <div class="flex--item ws-nowrap mb8" title="Viewed 287 times">
+ <span class="fc-black-400 mr2">Viewed</span>
+ 287 times
+ </div>
+ </div>
+
+ <div id="mainbar" role="main" aria-label="question and answers">
+
+<div class="question js-question" data-questionid="7015668" data-position-on-page="0" data-score="2" id="question">
+ <style>
+ </style>
+<div class="js-zone-container zone-container-main">
+ <div id="dfp-tlb" class="everyonelovesstackoverflow everyoneloves__top-leaderboard everyoneloves__leaderboard"></div>
+ <div class="js-report-ad-button-container " style="width: 728px"></div>
+</div>
+
+
+ <div class="post-layout ">
+ <div class="votecell post-layout--left">
+ <div class="js-voting-container d-flex jc-center fd-column ai-stretch gs4 fc-black-300" data-post-id="7015668" data-referrer="None">
+ <button class="js-vote-up-btn flex--item s-btn ba bar-pill c-pointer as-center bc-black-225 fc-black-500 h:bg-theme-primary-200"
+ data-controller="s-tooltip"
+ data-s-tooltip-placement="right"
+ title="This question shows research effort; it is useful and clear"
+ aria-pressed="false"
+ aria-label="Up vote"
+ data-selected-classes="fc-theme-primary bc-theme-primary bg-theme-primary-100"
+ data-unselected-classes="bc-black-225 fc-black-500 h:bg-theme-primary-200">
+ <svg aria-hidden="true" class="svg-icon iconArrowUp" width="18" height="18" viewBox="0 0 18 18"><path d="M1 12h16L9 4l-8 8Z"/></svg>
+ </button>
+ <div class="js-vote-count flex--item d-flex fd-column ai-center fc-theme-body-font fw-bold fs-subheading py4"
+ itemprop="upvoteCount"
+ data-value="2">
+ 2
+ </div>
+ <button class="js-vote-down-btn flex--item mb8 s-btn ba bar-pill c-pointer as-center bc-black-225 fc-black-500 h:bg-theme-primary-200"
+ data-controller="s-tooltip"
+ data-s-tooltip-placement="right"
+ title="This question does not show any research effort; it is unclear or not useful"
+ aria-pressed="false"
+ aria-label="Down vote"
+ data-selected-classes="fc-theme-primary bc-theme-primary bg-theme-primary-100"
+ data-unselected-classes="bc-black-225 fc-black-500 h:bg-theme-primary-200">
+ <svg aria-hidden="true" class="svg-icon iconArrowDown" width="18" height="18" viewBox="0 0 18 18"><path d="M1 6h16l-8 8-8-8Z"/></svg>
+ </button>
+
+
+
+<button class="js-saves-btn s-btn s-btn__unset c-pointer py4"
+ type="button"
+ id="saves-btn-7015668"
+ data-controller="s-tooltip"
+ data-s-tooltip-placement="right"
+ data-s-popover-placement=""
+ title="Save this question."
+ aria-pressed="false"
+ data-post-id="7015668"
+ data-post-type-id="1"
+ data-user-privilege-for-post-click="0"
+ aria-controls=""
+ data-s-popover-auto-show="false"
+>
+ <svg aria-hidden="true" class="fc-theme-primary-400 js-saves-btn-selected d-none svg-icon iconBookmark" width="18" height="18" viewBox="0 0 18 18"><path d="M3 17V3c0-1.1.9-2 2-2h8a2 2 0 0 1 2 2v14l-6-4-6 4Z"/></svg>
+ <svg aria-hidden="true" class="js-saves-btn-unselected svg-icon iconBookmarkAlt" width="18" height="18" viewBox="0 0 18 18"><path d="m9 10.6 4 2.66V3H5v10.26l4-2.66ZM3 17V3c0-1.1.9-2 2-2h8a2 2 0 0 1 2 2v14l-6-4-6 4Z"/></svg>
+</button>
+
+
+
+
+
+
+
+
+
+ <a class="js-post-issue flex--item s-btn s-btn__unset c-pointer py6 mx-auto" href="/posts/7015668/timeline" data-shortcut="T" data-ks-title="timeline" data-controller="s-tooltip" data-s-tooltip-placement="right" title="Show activity on this post." aria-label="Timeline"><svg aria-hidden="true" class="mln2 mr0 svg-icon iconHistory" width="19" height="18" viewBox="0 0 19 18"><path d="M3 9a8 8 0 1 1 3.73 6.77L8.2 14.3A6 6 0 1 0 5 9l3.01-.01-4 4-4-4h3L3 9Zm7-4h1.01L11 9.36l3.22 2.1-.6.93L10 10V5Z"/></svg></a>
+
+</div>
+
+ </div>
+
+
+
+<div class="postcell post-layout--right">
+
+ <div class="s-prose js-post-body" itemprop="text">
+
+<p>I'm extending my <a href="https://stackoverflow.com/questions/7002642/javascript-variable-scope-in-event-handler">previous question</a>, because I still don't fully understand the concept of javascript closures. Take a quick look at the following code, which will put two markers on a map. (The code is slightly modified from my previous question). </p>
+
+<pre><code>var map = google.maps.somefunctoinstantiatemap();
+var address = new Array();
+address[0] = '1 Smith Street';
+address[1] = '2 Smith Street';
+function onpageload()
+{
+for(var rownum=0; rownum&lt;address.length; rownum++)
+{
+ geocoder.geocode({
+ 'address': address[rownum]
+ }, function(results, status) {
+ geocodeCallBack(results,status,rownum)
+ });
+}
+}
+
+function geocodeCallBack(results, status, argnum)
+{
+ var marker = new google.maps.Marker({
+ map: map,
+ position: results[0].geometry.location,
+ title: 'arg: '+argnum+' addr:'+results[0].formatted_address
+ });
+
+ google.maps.event.addListener(marker, 'click', function(){
+ var infowindow = new google.maps.InfoWindow({
+ content: marker.title
+ });
+ infowindow.open(map, marker);
+ });
+}
+</code></pre>
+
+<p>Ok, multiple choice....what is the result when user clicks on both markers?</p>
+
+<ol>
+<li>first marker displays 'arg: 0 addr: 1 Smith Street' and second marker displays 'arg: 1 addr: 2 Smith Street'</li>
+<li>first marker displays 'arg: 0 addr: 2 Smith Street' and second marker displays 'arg: 1 addr: 2 Smith Street'</li>
+<li>first marker displays 'arg: 1 addr: 1 Smith Street' and second marker displays 'arg: 1 addr: 2 Smith Street'</li>
+<li>first marker displays 'arg: 1 addr: 2 Smith Street' and second marker displays 'arg: 1 addr: 2 Smith Street'</li>
+<li>first marker displays 'arg: undefined addr: undefined' and second marker display 'arg: undefined addr: undefined'</li>
+</ol>
+
+<p>When I run the code, the answer is 3. But I was expecting the answer to be either 4 or 5. Why is it not 4 and why is it not 5?</p>
+ </div>
+
+ <div class="mt24 mb12">
+ <div class="post-taglist d-flex gs4 gsy fd-column">
+ <div class="d-flex ps-relative fw-wrap">
+
+ <ul class='ml0 list-ls-none js-post-tag-list-wrapper d-inline'><li class='d-inline mr4 js-post-tag-list-item'><a href="/questions/tagged/javascript" class="post-tag" title="show questions tagged &#39;javascript&#39;" aria-label="show questions tagged &#39;javascript&#39;" rel="tag" aria-labelledby="tag-javascript-tooltip-container">javascript</a></li><li class='d-inline mr4 js-post-tag-list-item'><a href="/questions/tagged/closures" class="post-tag" title="show questions tagged &#39;closures&#39;" aria-label="show questions tagged &#39;closures&#39;" rel="tag" aria-labelledby="tag-closures-tooltip-container">closures</a></li></ul>
+ </div>
+ </div>
+ </div>
+
+ <div class="mb0 ">
+ <div class="mt16 d-flex gs8 gsy fw-wrap jc-end ai-start pt4 mb16">
+ <div class="flex--item mr16 fl1 w96">
+
+
+
+<div class="js-post-menu pt2" data-post-id="7015668" data-post-type-id="1">
+
+ <div class="d-flex gs8 s-anchors s-anchors__muted fw-wrap">
+
+ <div class="flex--item">
+ <a href="/q/7015668"
+ rel="nofollow"
+ itemprop="url"
+ class="js-share-link js-gps-track"
+ title="Short permalink to this question"
+ data-gps-track="post.click({ item: 2, priv: 0, post_type: 1 })"
+ data-controller="se-share-sheet"
+ data-se-share-sheet-title="Share a link to this question"
+ data-se-share-sheet-subtitle=""
+ data-se-share-sheet-post-type="question"
+ data-se-share-sheet-social="facebook twitter devto"
+ data-se-share-sheet-location="1"
+ data-se-share-sheet-license-url="https%3a%2f%2fcreativecommons.org%2flicenses%2fby-sa%2f3.0%2f"
+ data-se-share-sheet-license-name="CC BY-SA 3.0"
+ data-s-popover-placement="bottom-start">Share</a>
+ </div>
+
+
+ <div class="flex--item">
+ <a href="/posts/7015668/edit" class="js-suggest-edit-post js-gps-track" data-gps-track="post.click({ item: 6, priv: 0, post_type: 1 })" title="">Improve this question</a>
+ </div>
+
+ <div class="flex--item">
+ <button type="button"
+ id="btnFollowPost-7015668" class="s-btn s-btn__link js-follow-post js-follow-question js-gps-track"
+ data-gps-track="post.click({ item: 14, priv: 0, post_type: 1 })"
+ data-controller="s-tooltip " data-s-tooltip-placement="bottom"
+ data-s-popover-placement="bottom" aria-controls=""
+ title="Follow this question to receive notifications">
+ Follow
+ </button>
+ </div>
+
+
+
+
+
+
+ </div>
+ <div class="js-menu-popup-container"></div>
+</div>
+ </div>
+
+ <div class="post-signature flex--item">
+<div class="user-info user-hover ">
+ <div class="user-action-time">
+ <a href="/posts/7015668/revisions" title="show all edits to this post"
+ class="js-gps-track"
+ data-gps-track="post.click({ item: 4, priv: 0, post_type: 1 })">edited <span title='2017-05-23 12:19:51Z' class='relativetime'>May 23, 2017 at 12:19</span></a>
+ </div>
+ <div class="user-gravatar32">
+ <a href="/users/-1/community"><div class="gravatar-wrapper-32"><img src="https://www.gravatar.com/avatar/a007be5a61f6aa8f3e85ae2fc18dd66e?s=64&amp;d=identicon&amp;r=PG" alt="Community&#39;s user avatar" width="32" height="32" class="bar-sm"></div></a>
+ </div>
+ <div class="user-details">
+ <a href="/users/-1/community">Community</a><span class="flex--item s-badge ml2 s-badge__xs mtn2" title="Community Bot — not a real person. Replies to this bot are not monitored.">Bot</span>
+ <div class="-flair">
+ <span class="reputation-score" title="reputation score " dir="ltr">1</span><span title="1 silver badge" aria-hidden="true"><span class="badge2"></span><span class="badgecount">1</span></span><span class="v-visible-sr">1 silver badge</span>
+ </div>
+ </div>
+</div>
+ </div>
+ <div class="post-signature owner flex--item">
+ <div class="user-info user-hover ">
+ <div class="user-action-time">
+ asked <span title='2011-08-10 18:12:48Z' class='relativetime'>Aug 10, 2011 at 18:12</span>
+ </div>
+ <div class="user-gravatar32">
+ <a href="/users/27305/john"><div class="gravatar-wrapper-32"><img src="https://www.gravatar.com/avatar/174ac998689321daaa7cfecf910522e4?s=64&amp;d=identicon&amp;r=PG" alt="John&#39;s user avatar" width="32" height="32" class="bar-sm"></div></a>
+ </div>
+ <div class="user-details" itemprop="author" itemscope itemtype="http://schema.org/Person">
+ <a href="/users/27305/john">John</a><span class="d-none" itemprop="name">John</span>
+ <div class="-flair">
+ <span class="reputation-score" title="reputation score 32,669" dir="ltr">32.7k</span><span title="81 gold badges" aria-hidden="true"><span class="badge1"></span><span class="badgecount">81</span></span><span class="v-visible-sr">81 gold badges</span><span title="253 silver badges" aria-hidden="true"><span class="badge2"></span><span class="badgecount">253</span></span><span class="v-visible-sr">253 silver badges</span><span title="426 bronze badges" aria-hidden="true"><span class="badge3"></span><span class="badgecount">426</span></span><span class="v-visible-sr">426 bronze badges</span>
+ </div>
+ </div>
+</div>
+
+
+ </div>
+ </div>
+ </div>
+
+</div>
+
+
+
+
+ <span class="d-none" itemprop="commentCount">3</span>
+ <div class="post-layout--right js-post-comments-component">
+ <div id="comments-7015668" class="comments js-comments-container bt bc-black-200 mt12 " data-post-id="7015668" data-min-length="15">
+ <ul class="comments-list js-comments-list"
+ data-remaining-comments-count="0"
+ data-canpost="false"
+ data-cansee="true"
+ data-comments-unavailable="false"
+ data-addlink-disabled="true">
+
+ <li id="comment-8377911" class="comment js-comment " data-comment-id="8377911" data-comment-owner-id="157247" data-comment-score="0">
+ <div class="js-comment-actions comment-actions">
+ <div class="comment-score js-comment-score js-comment-edit-hide">
+ </div>
+ </div>
+ <div class="comment-text js-comment-text-and-form">
+ <div class="comment-body js-comment-edit-hide">
+
+ <span class="comment-copy">I think that can&#39;t be your real code, not least because your <code>for</code> loop up top is looping <i>three</i>, not two, times. Also, you seem to have plucked a <code>map</code> variable out of nowhere (nowhere you show, anyway).</span>
+
+ <div class="d-inline-flex ai-center">
+&ndash;&nbsp;<a href="/users/157247/t-j-crowder"
+ title="1,043,200 reputation"
+ class="comment-user">T.J. Crowder</a>
+ </div>
+ <span class="comment-date" dir="ltr"><span title='2011-08-10 18:18:11Z, License: CC BY-SA 3.0' class='relativetime-clean'>Aug 10, 2011 at 18:18</span></span>
+ </div>
+ </div>
+ </li>
+ <li id="comment-8377969" class="comment js-comment " data-comment-id="8377969" data-comment-owner-id="5921" data-comment-score="0">
+ <div class="js-comment-actions comment-actions">
+ <div class="comment-score js-comment-score js-comment-edit-hide">
+ </div>
+ </div>
+ <div class="comment-text js-comment-text-and-form">
+ <div class="comment-body js-comment-edit-hide">
+
+ <span class="comment-copy">This is missing a ton of info. &quot;What is the result&quot; of what? You gave two functions with no calls to either function and you reference Markers without any explanation. If anything this seems like a Google Maps, question, not a closures one.</span>
+
+ <div class="d-inline-flex ai-center">
+&ndash;&nbsp;<a href="/users/5921/machineghost"
+ title="34,102 reputation"
+ class="comment-user">machineghost</a>
+ </div>
+ <span class="comment-date" dir="ltr"><span title='2011-08-10 18:21:31Z, License: CC BY-SA 3.0' class='relativetime-clean'>Aug 10, 2011 at 18:21</span></span>
+ </div>
+ </div>
+ </li>
+ <li id="comment-8378004" class="comment js-comment " data-comment-id="8378004" data-comment-owner-id="27305" data-comment-score="0">
+ <div class="js-comment-actions comment-actions">
+ <div class="comment-score js-comment-score js-comment-edit-hide">
+ </div>
+ </div>
+ <div class="comment-text js-comment-text-and-form">
+ <div class="comment-body js-comment-edit-hide">
+
+ <span class="comment-copy">@T.J. Crowder - ok, i fixed up those errors...</span>
+
+ <div class="d-inline-flex ai-center">
+&ndash;&nbsp;<a href="/users/27305/john"
+ title="32,669 reputation"
+ class="comment-user owner">John</a>
+ </div>
+ <span class="comment-date" dir="ltr"><span title='2011-08-10 18:23:33Z, License: CC BY-SA 3.0' class='relativetime-clean'>Aug 10, 2011 at 18:23</span></span>
+ </div>
+ </div>
+ </li>
+
+ </ul>
+ </div>
+
+ <div id="comments-link-7015668" data-rep=50 data-anon=true>
+ <a class="js-add-link comments-link disabled-link" title="Use comments to ask for more information or suggest improvements. Avoid answering questions in comments." href="#" role="button">Add a comment</a>
+ <span class="js-link-separator dno">&nbsp;|&nbsp;</span>
+ <a class="js-show-link comments-link dno" title="Expand to show all comments on this post" href=# onclick="" role="button"></a>
+ </div>
+ </div>
+ </div>
+
+</div>
+
+
+<div class="js-zone-container zone-container-responsive">
+ <div id="dfp-isb" class="everyonelovesstackoverflow everyoneloves__inline-sidebar mx-auto"></div>
+ <div class="js-report-ad-button-container mx-auto" style="width: 300px"></div>
+</div>
+
+
+
+ <div id="answers">
+ <a name="tab-top"></a>
+ <div id="answers-header">
+ <div class="answers-subheader d-flex ai-center mb8">
+ <div class="flex--item fl1">
+ <h2 class="mb0" data-answercount="2">
+ 2 Answers
+ <span style="display:none;" itemprop="answerCount">2</span>
+ </h2>
+ </div>
+ <div class="flex--item">
+
+
+<div class="d-flex g4 gsx ai-center sm:fd-column sm:ai-start">
+ <div class="d-flex fd-column ai-end sm:ai-start">
+ <label class="flex--item fs-caption" for="answer-sort-dropdown-select-menu">
+ Sorted by:
+ </label>
+ <a
+ class="js-sort-preference-change s-link flex--item fs-fine d-none"
+ data-value="ScoreDesc"
+ href="/questions/7015668/javascript-closures-and-variable-scope?answertab=scoredesc#tab-top"
+ >
+ Reset to default
+ </a>
+ </div>
+ <div class="flex--item s-select">
+ <select id="answer-sort-dropdown-select-menu">
+ <option
+ value=scoredesc
+ selected=selected
+ >
+ Highest score (default)
+ </option>
+ <option
+ value=trending
+ >
+ Trending (recent votes count more)
+ </option>
+ <option
+ value=modifieddesc
+ >
+ Date modified (newest first)
+ </option>
+ <option
+ value=createdasc
+ >
+ Date created (oldest first)
+ </option>
+ </select>
+ </div>
+</div>
+
+
+ </div>
+ </div>
+
+ </div>
+
+
+
+<a name="7015823"></a>
+<div id="answer-7015823" class="answer js-answer accepted-answer js-accepted-answer" data-answerid="7015823" data-parentid="7015668" data-score="4" data-position-on-page="1" data-highest-scored="1" data-question-has-accepted-highest-score="1" itemprop="acceptedAnswer" itemscope itemtype="https://schema.org/Answer">
+ <div class="post-layout">
+ <div class="votecell post-layout--left">
+ <div class="js-voting-container d-flex jc-center fd-column ai-stretch gs4 fc-black-300" data-post-id="7015823" data-referrer="None">
+ <button class="js-vote-up-btn flex--item s-btn ba bar-pill c-pointer as-center bc-black-225 fc-black-500 h:bg-theme-primary-200"
+ data-controller="s-tooltip"
+ data-s-tooltip-placement="right"
+ title="This answer is useful"
+ aria-pressed="false"
+ aria-label="Up vote"
+ data-selected-classes="fc-theme-primary bc-theme-primary bg-theme-primary-100"
+ data-unselected-classes="bc-black-225 fc-black-500 h:bg-theme-primary-200">
+ <svg aria-hidden="true" class="svg-icon iconArrowUp" width="18" height="18" viewBox="0 0 18 18"><path d="M1 12h16L9 4l-8 8Z"/></svg>
+ </button>
+ <div class="js-vote-count flex--item d-flex fd-column ai-center fc-theme-body-font fw-bold fs-subheading py4"
+ itemprop="upvoteCount"
+ data-value="4">
+ 4
+ </div>
+ <button class="js-vote-down-btn flex--item mb8 s-btn ba bar-pill c-pointer as-center bc-black-225 fc-black-500 h:bg-theme-primary-200"
+ data-controller="s-tooltip"
+ data-s-tooltip-placement="right"
+ title="This answer is not useful"
+ aria-pressed="false"
+ aria-label="Down vote"
+ data-selected-classes="fc-theme-primary bc-theme-primary bg-theme-primary-100"
+ data-unselected-classes="bc-black-225 fc-black-500 h:bg-theme-primary-200">
+ <svg aria-hidden="true" class="svg-icon iconArrowDown" width="18" height="18" viewBox="0 0 18 18"><path d="M1 6h16l-8 8-8-8Z"/></svg>
+ </button>
+
+
+
+<button class="js-saves-btn s-btn s-btn__unset c-pointer py4"
+ type="button"
+ id="saves-btn-7015823"
+ data-controller="s-tooltip"
+ data-s-tooltip-placement="right"
+ data-s-popover-placement=""
+ title="Save this answer."
+ aria-pressed="false"
+ data-post-id="7015823"
+ data-post-type-id="2"
+ data-user-privilege-for-post-click="0"
+ aria-controls=""
+ data-s-popover-auto-show="false"
+>
+ <svg aria-hidden="true" class="fc-theme-primary-400 js-saves-btn-selected d-none svg-icon iconBookmark" width="18" height="18" viewBox="0 0 18 18"><path d="M3 17V3c0-1.1.9-2 2-2h8a2 2 0 0 1 2 2v14l-6-4-6 4Z"/></svg>
+ <svg aria-hidden="true" class="js-saves-btn-unselected svg-icon iconBookmarkAlt" width="18" height="18" viewBox="0 0 18 18"><path d="m9 10.6 4 2.66V3H5v10.26l4-2.66ZM3 17V3c0-1.1.9-2 2-2h8a2 2 0 0 1 2 2v14l-6-4-6 4Z"/></svg>
+</button>
+
+
+
+
+
+
+
+ <div class="js-accepted-answer-indicator flex--item fc-green-400 py6 mtn8" data-s-tooltip-placement="right" title="Loading when this answer was accepted&#x2026;" tabindex="0" role="note" aria-label="Accepted">
+ <div class="ta-center">
+ <svg aria-hidden="true" class="svg-icon iconCheckmarkLg" width="36" height="36" viewBox="0 0 36 36"><path d="m6 14 8 8L30 6v8L14 30l-8-8v-8Z"/></svg>
+ </div>
+ </div>
+
+
+ <a class="js-post-issue flex--item s-btn s-btn__unset c-pointer py6 mx-auto" href="/posts/7015823/timeline" data-shortcut="T" data-ks-title="timeline" data-controller="s-tooltip" data-s-tooltip-placement="right" title="Show activity on this post." aria-label="Timeline"><svg aria-hidden="true" class="mln2 mr0 svg-icon iconHistory" width="19" height="18" viewBox="0 0 19 18"><path d="M3 9a8 8 0 1 1 3.73 6.77L8.2 14.3A6 6 0 1 0 5 9l3.01-.01-4 4-4-4h3L3 9Zm7-4h1.01L11 9.36l3.22 2.1-.6.93L10 10V5Z"/></svg></a>
+
+</div>
+
+ </div>
+
+
+
+<div class="answercell post-layout--right">
+
+ <div class="s-prose js-post-body" itemprop="text">
+<p>You seem to be expecting the closure to close over something (which it does), but you're not using anything in particular that it closes over in it (like the loop index). The <code>argnum</code> value you get in your <code>geocodeCallBack</code> comes from Google (because you've defined <code>rownum</code> as the third argument to your anonymous function, <a href="http://en.wikipedia.org/wiki/Variable_shadowing" rel="nofollow">shadowing</a> the loop counter), it's nothing to do with your loop counter.</p>
+
+<p>A few other points about that code:</p>
+
+<p><s>Your loop at the top is looping <em>three</em> times, not two. You have it going from <code>0</code> to <code>&lt;= results.length</code>. <code>results.length</code> is <code>2</code>, and so that will loop with <code>rownum</code> values <code>0</code>, <code>1</code>, and <code>2</code>. You mean <code>&lt; results.length</code>.</s> <em>(You've fixed this.)</em></p>
+
+<p><s>There's no purpose to your anonymous function here:</p>
+
+<pre><code>geocoder.geocode( {'address': address[rownum]}, function(results, status, rownum) {geocodeCallBack(results,status,rownum)});
+</code></pre>
+
+<p>...since all it does is pass on the arguments it receives. That can and probably should just be:</p>
+
+<pre><code>geocoder.geocode( {'address': address[rownum]}, geocodeCallBack);
+</code></pre>
+
+<p>...unless the signature of the function is wrong and you shouldn't be declaring all of those arguments to it.</s></p>
+
+<p><strong>Edit</strong>: Based on your comments below, I think you may want this:</p>
+
+<pre><code>geocoder.geocode( {'address': address[rownum]}, makeCallback(rownum));
+
+function makeCallback(therow) {
+ return function(results, status) {
+ geocodeCallBack(results, status, therow);
+ };
+}
+</code></pre>
+
+<p>...or in your "real code" as you put it, where you're actually using that row number as part of a selector:</p>
+
+<pre><code>geocoder.geocode( {'address': address[rownum]}, makeCallback(rownum));
+
+function makeCallback(therow) {
+ return function(results, status) {
+ geocodeCallBack(results, status, $('#row-' + therow).val());
+ };
+}
+</code></pre>
+
+<p>The <code>makeCallback</code> function creates a function to be the callback. The function it creates closes over the <code>therow</code> argument passed into <code>makeCallback</code>, which never changes, and so you get <code>therow</code> being <code>0</code> for the callback you create on the first loop, and <code>therow</code> being <code>1</code> for the callback you create on the second loop.</p>
+
+<p>In terms of understanding closures, I've written up this post which I think you may find helpful: <a href="http://blog.niftysnippets.org/2008/02/closures-are-not-complicated.html" rel="nofollow"><em>Closures are not complicated</em></a> It goes into the mechanics of how closures work in some detail. And the title is no lie: They're <em>not</em> complicated, people tend to tie themselves up in knots because they <em>think</em> they're complicated, but they're not.</p>
+ </div>
+ <div class="mt24">
+ <div class="d-flex fw-wrap ai-start jc-end gs8 gsy">
+ <time itemprop="dateCreated" datetime="2011-08-10T18:24:53"></time>
+ <div class="flex--item mr16" style="flex: 1 1 100px;">
+
+
+
+<div class="js-post-menu pt2" data-post-id="7015823" data-post-type-id="2">
+
+ <div class="d-flex gs8 s-anchors s-anchors__muted fw-wrap">
+
+ <div class="flex--item">
+ <a href="/a/7015823"
+ rel="nofollow"
+ itemprop="url"
+ class="js-share-link js-gps-track"
+ title="Short permalink to this answer"
+ data-gps-track="post.click({ item: 2, priv: 0, post_type: 2 })"
+ data-controller="se-share-sheet"
+ data-se-share-sheet-title="Share a link to this answer"
+ data-se-share-sheet-subtitle=""
+ data-se-share-sheet-post-type="answer"
+ data-se-share-sheet-social="facebook twitter devto"
+ data-se-share-sheet-location="2"
+ data-se-share-sheet-license-url="https%3a%2f%2fcreativecommons.org%2flicenses%2fby-sa%2f3.0%2f"
+ data-se-share-sheet-license-name="CC BY-SA 3.0"
+ data-s-popover-placement="bottom-start">Share</a>
+ </div>
+
+
+ <div class="flex--item">
+ <a href="/posts/7015823/edit" class="js-suggest-edit-post js-gps-track" data-gps-track="post.click({ item: 6, priv: 0, post_type: 2 })" title="">Improve this answer</a>
+ </div>
+
+ <div class="flex--item">
+ <button type="button"
+ id="btnFollowPost-7015823" class="s-btn s-btn__link js-follow-post js-follow-answer js-gps-track"
+ data-gps-track="post.click({ item: 14, priv: 0, post_type: 2 })"
+ data-controller="s-tooltip " data-s-tooltip-placement="bottom"
+ data-s-popover-placement="bottom" aria-controls=""
+ title="Follow this answer to receive notifications">
+ Follow
+ </button>
+ </div>
+
+
+
+
+
+
+ </div>
+ <div class="js-menu-popup-container"></div>
+</div>
+ </div>
+ <div class="post-signature flex--item fl0">
+<div class="user-info ">
+ <div class="user-action-time">
+ <a href="/posts/7015823/revisions" title="show all edits to this post"
+ class="js-gps-track"
+ data-gps-track="post.click({ item: 4, priv: 0, post_type: 2 })">edited <span title='2011-08-10 18:34:24Z' class='relativetime'>Aug 10, 2011 at 18:34</span></a>
+ </div>
+ <div class="user-gravatar32">
+
+ </div>
+ <div class="user-details">
+
+ <div class="-flair">
+
+ </div>
+ </div>
+</div>
+ </div>
+
+
+ <div class="post-signature flex--item fl0">
+ <div class="user-info user-hover ">
+ <div class="user-action-time">
+ answered <span title='2011-08-10 18:24:53Z' class='relativetime'>Aug 10, 2011 at 18:24</span>
+ </div>
+ <div class="user-gravatar32">
+ <a href="/users/157247/t-j-crowder"><div class="gravatar-wrapper-32"><img src="https://i.stack.imgur.com/lUM5Z.jpg?s=64&amp;g=1" alt="T.J. Crowder&#39;s user avatar" width="32" height="32" class="bar-sm"></div></a>
+ </div>
+ <div class="user-details" itemprop="author" itemscope itemtype="http://schema.org/Person">
+ <a href="/users/157247/t-j-crowder">T.J. Crowder</a><span class="d-none" itemprop="name">T.J. Crowder</span>
+ <div class="-flair">
+ <span class="reputation-score" title="reputation score 1,043,200" dir="ltr">1.0m</span><span title="188 gold badges" aria-hidden="true"><span class="badge1"></span><span class="badgecount">188</span></span><span class="v-visible-sr">188 gold badges</span><span title="1941 silver badges" aria-hidden="true"><span class="badge2"></span><span class="badgecount">1941</span></span><span class="v-visible-sr">1941 silver badges</span><span title="1889 bronze badges" aria-hidden="true"><span class="badge3"></span><span class="badgecount">1889</span></span><span class="v-visible-sr">1889 bronze badges</span>
+ </div>
+ </div>
+</div>
+
+
+ </div>
+ </div>
+
+
+ </div>
+
+</div>
+
+
+
+
+ <span class="d-none" itemprop="commentCount">10</span>
+ <div class="post-layout--right js-post-comments-component">
+ <div id="comments-7015823" class="comments js-comments-container bt bc-black-200 mt12 " data-post-id="7015823" data-min-length="15">
+ <ul class="comments-list js-comments-list"
+ data-remaining-comments-count="5"
+ data-canpost="false"
+ data-cansee="true"
+ data-comments-unavailable="false"
+ data-addlink-disabled="true">
+
+ <li id="comment-8378108" class="comment js-comment " data-comment-id="8378108" data-comment-owner-id="27305" data-comment-score="0">
+ <div class="js-comment-actions comment-actions">
+ <div class="comment-score js-comment-score js-comment-edit-hide">
+ </div>
+ </div>
+ <div class="comment-text js-comment-text-and-form">
+ <div class="comment-body js-comment-edit-hide">
+
+ <span class="comment-copy">in my real code, I have something like this <code>geocoder.geocode( {&#39;address&#39;: address[rownum]}, function(results, status) { geocodeCallBack(results,status, $(&#39;#row-&#39;+rownum).val())}</code>. The problem is that rownum seems to always be hte value 1.</span>
+
+ <div class="d-inline-flex ai-center">
+&ndash;&nbsp;<a href="/users/27305/john"
+ title="32,669 reputation"
+ class="comment-user owner">John</a>
+ </div>
+ <span class="comment-date" dir="ltr"><span title='2011-08-10 18:29:36Z, License: CC BY-SA 3.0' class='relativetime-clean'>Aug 10, 2011 at 18:29</span></span>
+ <span title="this comment was edited 1 time">
+ <svg aria-hidden="true" class="va-text-bottom o50 svg-icon iconPencilSm" width="14" height="14" viewBox="0 0 14 14"><path fill="#F1B600" d="m2 10.12 6.37-6.43 1.88 1.88L3.88 12H2v-1.88Z"/><path fill="#E87C87" d="m11.1 1.71 1.13 1.12c.2.2.2.51 0 .71L11.1 4.7 9.21 2.86l1.17-1.15c.2-.2.51-.2.71 0Z"/></svg>
+ </span>
+ </div>
+ </div>
+ </li>
+ <li id="comment-8378133" class="comment js-comment " data-comment-id="8378133" data-comment-owner-id="157247" data-comment-score="0">
+ <div class="js-comment-actions comment-actions">
+ <div class="comment-score js-comment-score js-comment-edit-hide">
+ </div>
+ </div>
+ <div class="comment-text js-comment-text-and-form">
+ <div class="comment-body js-comment-edit-hide">
+
+ <span class="comment-copy">@John: That value is coming from Google, it&#39;s nothing to do with your loop counter. You&#39;ve declared <code>rownum</code> as the third argument the anonymous function accepts, so within the anonymous function, it&#39;s going to have whatever value Google passes to the callback as the third argument. Unless you&#39;re intentionally receiving that third argument, don&#39;t declare it. Then you won&#39;t be shadowing <code>rownum</code> -- and then you&#39;ll have the problem you expect, because by the time the function gets called, <code>rownum</code> will be <code>2</code>, not <code>0</code> or <code>1</code>.</span>
+
+ <div class="d-inline-flex ai-center">
+&ndash;&nbsp;<a href="/users/157247/t-j-crowder"
+ title="1,043,200 reputation"
+ class="comment-user">T.J. Crowder</a>
+ </div>
+ <span class="comment-date" dir="ltr"><span title='2011-08-10 18:31:15Z, License: CC BY-SA 3.0' class='relativetime-clean'>Aug 10, 2011 at 18:31</span></span>
+ <span title="this comment was edited 1 time">
+ <svg aria-hidden="true" class="va-text-bottom o50 svg-icon iconPencilSm" width="14" height="14" viewBox="0 0 14 14"><path fill="#F1B600" d="m2 10.12 6.37-6.43 1.88 1.88L3.88 12H2v-1.88Z"/><path fill="#E87C87" d="m11.1 1.71 1.13 1.12c.2.2.2.51 0 .71L11.1 4.7 9.21 2.86l1.17-1.15c.2-.2.51-.2.71 0Z"/></svg>
+ </span>
+ </div>
+ </div>
+ </li>
+ <li id="comment-8378172" class="comment js-comment " data-comment-id="8378172" data-comment-owner-id="717383" data-comment-score="0">
+ <div class="js-comment-actions comment-actions">
+ <div class="comment-score js-comment-score js-comment-edit-hide">
+ </div>
+ </div>
+ <div class="comment-text js-comment-text-and-form">
+ <div class="comment-body js-comment-edit-hide">
+
+ <span class="comment-copy">While this was going to be my answer too, I can find no indication that the callback should pass a third argument. The doc says it passes just the first 2. Wonder if this is some undocumented parameter.</span>
+
+ <div class="d-inline-flex ai-center">
+&ndash;&nbsp;<a href="/users/717383/james-montagne"
+ title="77,796 reputation"
+ class="comment-user">James Montagne</a>
+ </div>
+ <span class="comment-date" dir="ltr"><span title='2011-08-10 18:33:34Z, License: CC BY-SA 3.0' class='relativetime-clean'>Aug 10, 2011 at 18:33</span></span>
+ </div>
+ </div>
+ </li>
+ <li id="comment-8378222" class="comment js-comment " data-comment-id="8378222" data-comment-owner-id="27305" data-comment-score="0">
+ <div class="js-comment-actions comment-actions">
+ <div class="comment-score js-comment-score js-comment-edit-hide">
+ </div>
+ </div>
+ <div class="comment-text js-comment-text-and-form">
+ <div class="comment-body js-comment-edit-hide">
+
+ <span class="comment-copy">@T.J. - bah sorry, there shouldn&#39;t be any 3rd arg in the anonymous function. I just corrected the comment.</span>
+
+ <div class="d-inline-flex ai-center">
+&ndash;&nbsp;<a href="/users/27305/john"
+ title="32,669 reputation"
+ class="comment-user owner">John</a>
+ </div>
+ <span class="comment-date" dir="ltr"><span title='2011-08-10 18:35:52Z, License: CC BY-SA 3.0' class='relativetime-clean'>Aug 10, 2011 at 18:35</span></span>
+ <span title="this comment was edited 2 times">
+ <svg aria-hidden="true" class="va-text-bottom o50 svg-icon iconPencilSm" width="14" height="14" viewBox="0 0 14 14"><path fill="#F1B600" d="m2 10.12 6.37-6.43 1.88 1.88L3.88 12H2v-1.88Z"/><path fill="#E87C87" d="m11.1 1.71 1.13 1.12c.2.2.2.51 0 .71L11.1 4.7 9.21 2.86l1.17-1.15c.2-.2.51-.2.71 0Z"/></svg>
+ </span>
+ </div>
+ </div>
+ </li>
+ <li id="comment-8378234" class="comment js-comment " data-comment-id="8378234" data-comment-owner-id="157247" data-comment-score="0">
+ <div class="js-comment-actions comment-actions">
+ <div class="comment-score js-comment-score js-comment-edit-hide">
+ </div>
+ </div>
+ <div class="comment-text js-comment-text-and-form">
+ <div class="comment-body js-comment-edit-hide">
+
+ <span class="comment-copy">@John: I&#39;ve updated the answer with what I think you&#39;re looking for.</span>
+
+ <div class="d-inline-flex ai-center">
+&ndash;&nbsp;<a href="/users/157247/t-j-crowder"
+ title="1,043,200 reputation"
+ class="comment-user">T.J. Crowder</a>
+ </div>
+ <span class="comment-date" dir="ltr"><span title='2011-08-10 18:36:37Z, License: CC BY-SA 3.0' class='relativetime-clean'>Aug 10, 2011 at 18:36</span></span>
+ </div>
+ </div>
+ </li>
+
+ </ul>
+ </div>
+
+ <div id="comments-link-7015823" data-rep=50 data-anon=true>
+ <a class="js-add-link comments-link dno" title="Use comments to ask for more information or suggest improvements. Avoid comments like &#x201C;&#x2B;1&#x201D; or &#x201C;thanks&#x201D;." href="#" role="button"></a>
+ <span class="js-link-separator dno">&nbsp;|&nbsp;</span>
+ <a class="js-show-link comments-link " title="Expand to show all comments on this post" href=# onclick="" role="button">Show <b>5</b> more comments</a>
+ </div>
+ </div>
+ </div>
+</div>
+
+<div class="js-zone-container zone-container-main">
+ <div id="dfp-mlb" class="everyonelovesstackoverflow everyoneloves__mid-leaderboard everyoneloves__leaderboard"></div>
+ <div class="js-report-ad-button-container " style="width: 728px"></div>
+</div>
+
+<a name="7015818"></a>
+<div id="answer-7015818" class="answer js-answer" data-answerid="7015818" data-parentid="7015668" data-score="0" data-position-on-page="2" data-highest-scored="0" data-question-has-accepted-highest-score="1" itemprop="suggestedAnswer" itemscope itemtype="https://schema.org/Answer">
+ <div class="post-layout">
+ <div class="votecell post-layout--left">
+ <div class="js-voting-container d-flex jc-center fd-column ai-stretch gs4 fc-black-300" data-post-id="7015818" data-referrer="None">
+ <button class="js-vote-up-btn flex--item s-btn ba bar-pill c-pointer as-center bc-black-225 fc-black-500 h:bg-theme-primary-200"
+ data-controller="s-tooltip"
+ data-s-tooltip-placement="right"
+ title="This answer is useful"
+ aria-pressed="false"
+ aria-label="Up vote"
+ data-selected-classes="fc-theme-primary bc-theme-primary bg-theme-primary-100"
+ data-unselected-classes="bc-black-225 fc-black-500 h:bg-theme-primary-200">
+ <svg aria-hidden="true" class="svg-icon iconArrowUp" width="18" height="18" viewBox="0 0 18 18"><path d="M1 12h16L9 4l-8 8Z"/></svg>
+ </button>
+ <div class="js-vote-count flex--item d-flex fd-column ai-center fc-theme-body-font fw-bold fs-subheading py4"
+ itemprop="upvoteCount"
+ data-value="0">
+ 0
+ </div>
+ <button class="js-vote-down-btn flex--item mb8 s-btn ba bar-pill c-pointer as-center bc-black-225 fc-black-500 h:bg-theme-primary-200"
+ data-controller="s-tooltip"
+ data-s-tooltip-placement="right"
+ title="This answer is not useful"
+ aria-pressed="false"
+ aria-label="Down vote"
+ data-selected-classes="fc-theme-primary bc-theme-primary bg-theme-primary-100"
+ data-unselected-classes="bc-black-225 fc-black-500 h:bg-theme-primary-200">
+ <svg aria-hidden="true" class="svg-icon iconArrowDown" width="18" height="18" viewBox="0 0 18 18"><path d="M1 6h16l-8 8-8-8Z"/></svg>
+ </button>
+
+
+
+<button class="js-saves-btn s-btn s-btn__unset c-pointer py4"
+ type="button"
+ id="saves-btn-7015818"
+ data-controller="s-tooltip"
+ data-s-tooltip-placement="right"
+ data-s-popover-placement=""
+ title="Save this answer."
+ aria-pressed="false"
+ data-post-id="7015818"
+ data-post-type-id="2"
+ data-user-privilege-for-post-click="0"
+ aria-controls=""
+ data-s-popover-auto-show="false"
+>
+ <svg aria-hidden="true" class="fc-theme-primary-400 js-saves-btn-selected d-none svg-icon iconBookmark" width="18" height="18" viewBox="0 0 18 18"><path d="M3 17V3c0-1.1.9-2 2-2h8a2 2 0 0 1 2 2v14l-6-4-6 4Z"/></svg>
+ <svg aria-hidden="true" class="js-saves-btn-unselected svg-icon iconBookmarkAlt" width="18" height="18" viewBox="0 0 18 18"><path d="m9 10.6 4 2.66V3H5v10.26l4-2.66ZM3 17V3c0-1.1.9-2 2-2h8a2 2 0 0 1 2 2v14l-6-4-6 4Z"/></svg>
+</button>
+
+
+
+
+
+
+
+ <div class="js-accepted-answer-indicator flex--item fc-green-400 py6 mtn8 d-none" data-s-tooltip-placement="right" title="Loading when this answer was accepted&#x2026;" tabindex="0" role="note" aria-label="Accepted">
+ <div class="ta-center">
+ <svg aria-hidden="true" class="svg-icon iconCheckmarkLg" width="36" height="36" viewBox="0 0 36 36"><path d="m6 14 8 8L30 6v8L14 30l-8-8v-8Z"/></svg>
+ </div>
+ </div>
+
+
+ <a class="js-post-issue flex--item s-btn s-btn__unset c-pointer py6 mx-auto" href="/posts/7015818/timeline" data-shortcut="T" data-ks-title="timeline" data-controller="s-tooltip" data-s-tooltip-placement="right" title="Show activity on this post." aria-label="Timeline"><svg aria-hidden="true" class="mln2 mr0 svg-icon iconHistory" width="19" height="18" viewBox="0 0 19 18"><path d="M3 9a8 8 0 1 1 3.73 6.77L8.2 14.3A6 6 0 1 0 5 9l3.01-.01-4 4-4-4h3L3 9Zm7-4h1.01L11 9.36l3.22 2.1-.6.93L10 10V5Z"/></svg></a>
+
+</div>
+
+ </div>
+
+
+
+<div class="answercell post-layout--right">
+
+ <div class="s-prose js-post-body" itemprop="text">
+<p>geocode() is overriding the value of numrow when you declare it as a function parameter.</p>
+
+<pre><code>for(var rownum=0; rownum&lt;=address.length; rownum++)
+{
+ geocoder.geocode( {'address': address[rownum]}, function(results, status) {geocodeCallBack(results,status,rownum)});
+}
+</code></pre>
+
+<p>Try this instead, this way geocodeCallBack is sent the rownum that is declared in the forloop</p>
+
+<p>The result should be first marker displays 'arg: 0 addr: 1 Smith Street' and second marker displays 'arg: 1 addr: 2 Smith Street'</p>
+ </div>
+ <div class="mt24">
+ <div class="d-flex fw-wrap ai-start jc-end gs8 gsy">
+ <time itemprop="dateCreated" datetime="2011-08-10T18:24:11"></time>
+ <div class="flex--item mr16" style="flex: 1 1 100px;">
+
+
+
+<div class="js-post-menu pt2" data-post-id="7015818" data-post-type-id="2">
+
+ <div class="d-flex gs8 s-anchors s-anchors__muted fw-wrap">
+
+ <div class="flex--item">
+ <a href="/a/7015818"
+ rel="nofollow"
+ itemprop="url"
+ class="js-share-link js-gps-track"
+ title="Short permalink to this answer"
+ data-gps-track="post.click({ item: 2, priv: 0, post_type: 2 })"
+ data-controller="se-share-sheet"
+ data-se-share-sheet-title="Share a link to this answer"
+ data-se-share-sheet-subtitle=""
+ data-se-share-sheet-post-type="answer"
+ data-se-share-sheet-social="facebook twitter devto"
+ data-se-share-sheet-location="2"
+ data-se-share-sheet-license-url="https%3a%2f%2fcreativecommons.org%2flicenses%2fby-sa%2f3.0%2f"
+ data-se-share-sheet-license-name="CC BY-SA 3.0"
+ data-s-popover-placement="bottom-start">Share</a>
+ </div>
+
+
+ <div class="flex--item">
+ <a href="/posts/7015818/edit" class="js-suggest-edit-post js-gps-track" data-gps-track="post.click({ item: 6, priv: 0, post_type: 2 })" title="">Improve this answer</a>
+ </div>
+
+ <div class="flex--item">
+ <button type="button"
+ id="btnFollowPost-7015818" class="s-btn s-btn__link js-follow-post js-follow-answer js-gps-track"
+ data-gps-track="post.click({ item: 14, priv: 0, post_type: 2 })"
+ data-controller="s-tooltip " data-s-tooltip-placement="bottom"
+ data-s-popover-placement="bottom" aria-controls=""
+ title="Follow this answer to receive notifications">
+ Follow
+ </button>
+ </div>
+
+
+
+
+
+
+ </div>
+ <div class="js-menu-popup-container"></div>
+</div>
+ </div>
+
+
+ <div class="post-signature flex--item fl0">
+ <div class="user-info user-hover ">
+ <div class="user-action-time">
+ answered <span title='2011-08-10 18:24:11Z' class='relativetime'>Aug 10, 2011 at 18:24</span>
+ </div>
+ <div class="user-gravatar32">
+ <a href="/users/823942/matt-r-wilson"><div class="gravatar-wrapper-32"><img src="https://www.gravatar.com/avatar/20a30fbd90856d74ec7b6ba78258b234?s=64&amp;d=identicon&amp;r=PG" alt="Matt R. Wilson&#39;s user avatar" width="32" height="32" class="bar-sm"></div></a>
+ </div>
+ <div class="user-details" itemprop="author" itemscope itemtype="http://schema.org/Person">
+ <a href="/users/823942/matt-r-wilson">Matt R. Wilson</a><span class="d-none" itemprop="name">Matt R. Wilson</span>
+ <div class="-flair">
+ <span class="reputation-score" title="reputation score " dir="ltr">7,346</span><span title="5 gold badges" aria-hidden="true"><span class="badge1"></span><span class="badgecount">5</span></span><span class="v-visible-sr">5 gold badges</span><span title="32 silver badges" aria-hidden="true"><span class="badge2"></span><span class="badgecount">32</span></span><span class="v-visible-sr">32 silver badges</span><span title="48 bronze badges" aria-hidden="true"><span class="badge3"></span><span class="badgecount">48</span></span><span class="v-visible-sr">48 bronze badges</span>
+ </div>
+ </div>
+</div>
+
+
+ </div>
+ </div>
+
+
+ </div>
+
+</div>
+
+
+
+
+ <span class="d-none" itemprop="commentCount">1</span>
+ <div class="post-layout--right js-post-comments-component">
+ <div id="comments-7015818" class="comments js-comments-container bt bc-black-200 mt12 " data-post-id="7015818" data-min-length="15">
+ <ul class="comments-list js-comments-list"
+ data-remaining-comments-count="0"
+ data-canpost="false"
+ data-cansee="true"
+ data-comments-unavailable="false"
+ data-addlink-disabled="true">
+
+ <li id="comment-8378200" class="comment js-comment " data-comment-id="8378200" data-comment-owner-id="157247" data-comment-score="2">
+ <div class="js-comment-actions comment-actions">
+ <div class="comment-score js-comment-score js-comment-edit-hide">
+ <span title="number of &#x27;useful comment&#x27; votes received"
+ class="cool">2</span>
+ </div>
+ </div>
+ <div class="comment-text js-comment-text-and-form">
+ <div class="comment-body js-comment-edit-hide">
+
+ <span class="comment-copy">If he does that, <code>geocodeCallback</code> will always see <code>2</code> as its third argument. Definitely not what the OP wants.</span>
+
+ <div class="d-inline-flex ai-center">
+&ndash;&nbsp;<a href="/users/157247/t-j-crowder"
+ title="1,043,200 reputation"
+ class="comment-user">T.J. Crowder</a>
+ </div>
+ <span class="comment-date" dir="ltr"><span title='2011-08-10 18:35:00Z, License: CC BY-SA 3.0' class='relativetime-clean'>Aug 10, 2011 at 18:35</span></span>
+ </div>
+ </div>
+ </li>
+
+ </ul>
+ </div>
+
+ <div id="comments-link-7015818" data-rep=50 data-anon=true>
+ <a class="js-add-link comments-link disabled-link" title="Use comments to ask for more information or suggest improvements. Avoid comments like &#x201C;&#x2B;1&#x201D; or &#x201C;thanks&#x201D;." href="#" role="button">Add a comment</a>
+ <span class="js-link-separator dno">&nbsp;|&nbsp;</span>
+ <a class="js-show-link comments-link dno" title="Expand to show all comments on this post" href=# onclick="" role="button"></a>
+ </div>
+ </div>
+ </div>
+</div>
+
+
+ <a name='new-answer'></a>
+ <form id="post-form" action="/questions/7015668/answer/submit" method="post" class="js-add-answer-component post-form">
+ <input type="hidden" id="post-id" value="7015668" />
+ <input type="hidden" id="qualityBanWarningShown" name="qualityBanWarningShown" value="false" />
+ <input type="hidden" name="referrer" value="https://trystract.com/" />
+ <h2 class="space" id="your-answer-header">
+ Your Answer
+ </h2>
+
+
+ <script>
+ StackExchange.ifUsing("editor", function () {
+ StackExchange.using("externalEditor", function () {
+ StackExchange.using("snippets", function () {
+ StackExchange.snippets.init();
+ });
+ });
+ }, "code-snippets");
+ </script>
+
+
+<script>
+ StackExchange.ready(function() {
+ var channelOptions = {
+ tags: "".split(" "),
+ id: "1"
+ };
+ initTagRenderer("".split(" "), "".split(" "), channelOptions);
+
+ StackExchange.using("externalEditor", function() {
+ // Have to fire editor after snippets, if snippets enabled
+ if (StackExchange.settings.snippets.snippetsEnabled) {
+ StackExchange.using("snippets", function() {
+ createEditor();
+ });
+ }
+ else {
+ createEditor();
+ }
+ });
+
+ function createEditor() {
+ StackExchange.prepareEditor({
+ useStacksEditor: false,
+ heartbeatType: 'answer',
+ autoActivateHeartbeat: false,
+ convertImagesToLinks: true,
+ noModals: true,
+ showLowRepImageUploadWarning: true,
+ reputationToPostImages: 10,
+ bindNavPrevention: true,
+ postfix: "",
+ imageUploader: {
+ brandingHtml: "Powered by \u003ca href=\"https://imgur.com/\"\u003e\u003csvg class=\"svg-icon\" width=\"50\" height=\"18\" viewBox=\"0 0 50 18\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\"\u003e\u003ctitle\u003eImgur Logo\u003c/title\u003e\u003cpath d=\"M46.1709 9.17788C46.1709 8.26454 46.2665 7.94324 47.1084 7.58816C47.4091 7.46349 47.7169 7.36433 48.0099 7.26993C48.9099 6.97997 49.672 6.73443 49.672 5.93063C49.672 5.22043 48.9832 4.61182 48.1414 4.61182C47.4335 4.61182 46.7256 4.91628 46.0943 5.50789C45.7307 4.9328 45.2525 4.66231 44.6595 4.66231C43.6264 4.66231 43.1481 5.28821 43.1481 6.59048V11.9512C43.1481 13.2535 43.6264 13.8962 44.6595 13.8962C45.6924 13.8962 46.1709 13.2535 46.1709 11.9512V9.17788Z\"/\u003e\u003cpath d=\"M32.492 10.1419C32.492 12.6954 34.1182 14.0484 37.0451 14.0484C39.9723 14.0484 41.5985 12.6954 41.5985 10.1419V6.59049C41.5985 5.28821 41.1394 4.66232 40.1061 4.66232C39.0732 4.66232 38.5948 5.28821 38.5948 6.59049V9.60062C38.5948 10.8521 38.2696 11.5455 37.0451 11.5455C35.8209 11.5455 35.4954 10.8521 35.4954 9.60062V6.59049C35.4954 5.28821 35.0173 4.66232 34.0034 4.66232C32.9703 4.66232 32.492 5.28821 32.492 6.59049V10.1419Z\" /\u003e\u003cpath fill-rule=\"evenodd\" clip-rule=\"evenodd\" d=\"M25.6622 17.6335C27.8049 17.6335 29.3739 16.9402 30.2537 15.6379C30.8468 14.7755 30.9615 13.5579 30.9615 11.9512V6.59049C30.9615 5.28821 30.4833 4.66231 29.4502 4.66231C28.9913 4.66231 28.4555 4.94978 28.1109 5.50789C27.499 4.86533 26.7335 4.56087 25.7005 4.56087C23.1369 4.56087 21.0134 6.57349 21.0134 9.27932C21.0134 11.9852 23.003 13.913 25.3754 13.913C26.5612 13.913 27.4607 13.4902 28.1109 12.6616C28.1109 12.7229 28.1161 12.7799 28.121 12.8346C28.1256 12.8854 28.1301 12.9342 28.1301 12.983C28.1301 14.4373 27.2502 15.2321 25.777 15.2321C24.8349 15.2321 24.1352 14.9821 23.5661 14.7787C23.176 14.6393 22.8472 14.5218 22.5437 14.5218C21.7977 14.5218 21.2429 15.0123 21.2429 15.6887C21.2429 16.7375 22.9072 17.6335 25.6622 17.6335ZM24.1317 9.27932C24.1317 7.94324 24.9928 7.09766 26.1024 7.09766C27.2119 7.09766 28.0918 7.94324 28.0918 9.27932C28.0918 10.6321 27.2311 11.5116 26.1024 11.5116C24.9737 11.5116 24.1317 10.6491 24.1317 9.27932Z\"/\u003e\u003cpath d=\"M16.8045 11.9512C16.8045 13.2535 17.2637 13.8962 18.2965 13.8962C19.3298 13.8962 19.8079 13.2535 19.8079 11.9512V8.12928C19.8079 5.82936 18.4879 4.62866 16.4027 4.62866C15.1594 4.62866 14.279 4.98375 13.3609 5.88013C12.653 5.05154 11.6581 4.62866 10.3573 4.62866C9.34336 4.62866 8.57809 4.89931 7.9466 5.5079C7.58314 4.9328 7.10506 4.66232 6.51203 4.66232C5.47873 4.66232 5.00066 5.28821 5.00066 6.59049V11.9512C5.00066 13.2535 5.47873 13.8962 6.51203 13.8962C7.54479 13.8962 8.0232 13.2535 8.0232 11.9512V8.90741C8.0232 7.58817 8.44431 6.91179 9.53458 6.91179C10.5104 6.91179 10.893 7.58817 10.893 8.94108V11.9512C10.893 13.2535 11.3711 13.8962 12.4044 13.8962C13.4375 13.8962 13.9157 13.2535 13.9157 11.9512V8.90741C13.9157 7.58817 14.3365 6.91179 15.4269 6.91179C16.4027 6.91179 16.8045 7.58817 16.8045 8.94108V11.9512Z\"/\u003e\u003cpath d=\"M3.31675 6.59049C3.31675 5.28821 2.83866 4.66232 1.82471 4.66232C0.791758 4.66232 0.313354 5.28821 0.313354 6.59049V11.9512C0.313354 13.2535 0.791758 13.8962 1.82471 13.8962C2.85798 13.8962 3.31675 13.2535 3.31675 11.9512V6.59049Z\" /\u003e\u003cpath d=\"M1.87209 0.400291C0.843612 0.400291 0 1.1159 0 1.98861C0 2.87869 0.822846 3.57676 1.87209 3.57676C2.90056 3.57676 3.7234 2.87869 3.7234 1.98861C3.7234 1.1159 2.90056 0.400291 1.87209 0.400291Z\" fill=\"#1BB76E\"/\u003e\u003c/svg\u003e\u003c/a\u003e",
+ contentPolicyHtml: "User contributions licensed under \u003ca href=\"https://stackoverflow.com/help/licensing\"\u003eCC BY-SA\u003c/a\u003e \u003ca href=\"https://stackoverflow.com/legal/acceptable-use-policy\"\u003e(content policy)\u003c/a\u003e",
+ allowUrls: true
+ },
+ onDemand: true,
+ discardSelector: ".discard-answer",
+ enableTables: true,
+ isStacksEditorPreviewEnabled: false
+ ,immediatelyShowMarkdownHelp:true,enableTables:true,enableSnippets:true
+ });
+ }
+ });
+</script>
+<div id="post-editor" class="post-editor js-post-editor">
+
+
+ <div class="ps-relative">
+ <div class="wmd-container mb8">
+ <div id="wmd-button-bar" class="wmd-button-bar btr-sm"></div>
+ <div class="js-stacks-validation">
+ <div class="ps-relative">
+ <textarea id="wmd-input"
+ name="post-text"
+ class="wmd-input s-input bar0 js-post-body-field"
+ data-editor-type="wmd"
+ data-post-type-id="2"
+ cols="92" rows="15"
+ aria-labelledby="your-answer-header"
+ tabindex="101"
+ data-min-length=""></textarea>
+ </div>
+ <div class="s-input-message mt4 d-none js-stacks-validation-message"></div>
+ </div>
+ </div>
+ </div>
+
+ <aside class="d-flex ai-start jc-space-between js-answer-help s-notice s-notice__warning pb0 pr4 pt4 mb8 d-none" role="status" aria-hidden="true">
+ <div class="flex--item pt8">
+ <p>Thanks for contributing an answer to Stack Overflow!</p><ul><li>Please be sure to <em>answer the question</em>. Provide details and share your research!</li></ul><p>But <em>avoid</em> …</p><ul><li>Asking for help, clarification, or responding to other answers.</li><li>Making statements based on opinion; back them up with references or personal experience.</li></ul><p>To learn more, see our <a href="/help/how-to-answer">tips on writing great answers</a>.</p>
+ </div>
+ <button class="flex--item js-answer-help-close-btn s-btn s-btn__muted fc-black-600">
+ <svg aria-hidden="true" class="svg-icon iconClear" width="18" height="18" viewBox="0 0 18 18"><path d="M15 4.41 13.59 3 9 7.59 4.41 3 3 4.41 7.59 9 3 13.59 4.41 15 9 10.41 13.59 15 15 13.59 10.41 9 15 4.41Z"/></svg>
+ </button>
+</aside>
+
+
+
+ <div>
+ <div id="draft-saved" class="fc-success h24" style="display:none;">Draft saved</div>
+ <div id="draft-discarded" class="fc-error h24" style="display:none;">Draft discarded</div>
+ </div>
+
+
+ <div id="wmd-preview" class="s-prose mb16 wmd-preview js-wmd-preview"></div>
+ <div></div>
+
+ <div class="edit-block">
+ <input id="fkey" name="fkey" type="hidden" value="103c124eeda5357e9b36b1f9707d5e0e098dc76d7770a150b1317852974be26a">
+ <input id="author" name="author" type="text">
+ </div>
+
+</div>
+
+
+ <div class="ps-relative">
+ <div class="form-item dno new-post-login p0 my16">
+ <div class="d-flex gs16 md:fd-column new-login-form">
+ <div class="d-flex fd-column w50 md:w-auto gsy gs8 jc-space-between new-login-left">
+ <h3 class="flex--item fs-title">Sign up or <a id="login-link" href="/users/login?ssrc=question_page&returnurl=https%3a%2f%2fstackoverflow.com%2fquestions%2f7015668%2fjavascript-closures-and-variable-scope%23new-answer">log in</a></h3>
+ <script>
+ StackExchange.ready(function () {
+ StackExchange.helpers.onClickDraftSave('#login-link');
+ });
+ </script>
+ <div class="flex--item s-btn s-btn__muted s-btn__outlined s-btn__icon google-login" data-ga="[&quot;sign up&quot;,&quot;Sign Up Started - Google&quot;,&quot;New Post&quot;,null,null]">
+ <svg aria-hidden="true" class="native svg-icon iconGoogle" width="18" height="18" viewBox="0 0 18 18"><path fill="#4285F4" d="M16.51 8H8.98v3h4.3c-.18 1-.74 1.48-1.6 2.04v2.01h2.6a7.8 7.8 0 0 0 2.38-5.88c0-.57-.05-.66-.15-1.18Z"/><path fill="#34A853" d="M8.98 17c2.16 0 3.97-.72 5.3-1.94l-2.6-2a4.8 4.8 0 0 1-7.18-2.54H1.83v2.07A8 8 0 0 0 8.98 17Z"/><path fill="#FBBC05" d="M4.5 10.52a4.8 4.8 0 0 1 0-3.04V5.41H1.83a8 8 0 0 0 0 7.18l2.67-2.07Z"/><path fill="#EA4335" d="M8.98 4.18c1.17 0 2.23.4 3.06 1.2l2.3-2.3A8 8 0 0 0 1.83 5.4L4.5 7.49a4.77 4.77 0 0 1 4.48-3.3Z"/></svg> Sign up using Google
+ </div>
+ <div class="flex--item s-btn s-btn__muted s-btn__icon facebook-login" data-ga="[&quot;sign up&quot;,&quot;Sign Up Started - Facebook&quot;,&quot;New Post&quot;,null,null]">
+ <svg aria-hidden="true" class="svg-icon iconFacebook" width="18" height="18" viewBox="0 0 18 18"><path fill="#4167B2" d="M3 1a2 2 0 0 0-2 2v12c0 1.1.9 2 2 2h12a2 2 0 0 0 2-2V3a2 2 0 0 0-2-2H3Zm6.55 16v-6.2H7.46V8.4h2.09V6.61c0-2.07 1.26-3.2 3.1-3.2.88 0 1.64.07 1.87.1v2.16h-1.29c-1 0-1.19.48-1.19 1.18V8.4h2.39l-.31 2.42h-2.08V17h-2.5Z"/></svg> Sign up using Facebook
+ </div>
+ <div class="flex--item s-btn s-btn__muted s-btn__outlined s-btn__icon stackexchange-login" data-ga="[&quot;sign up&quot;,&quot;Sign Up Navigation&quot;,&quot;New Post&quot;,null,null]">
+ <svg aria-hidden="true" class="native svg-icon iconLogoGlyphXSm" width="18" height="18" viewBox="0 0 18 18"><path d="M14 16v-5h2v7H2v-7h2v5h10Z" fill="#BCBBBB"/><path d="m12.09.72-1.21.9 4.5 6.07 1.22-.9L12.09.71ZM5 15h8v-2H5v2Zm9.15-5.87L8.35 4.3l.96-1.16 5.8 4.83-.96 1.16Zm-7.7-1.47 6.85 3.19.63-1.37-6.85-3.2-.63 1.38Zm6.53 5L5.4 11.39l.38-1.67 7.42 1.48-.22 1.46Z" fill="#F48024"/></svg> Sign up using Email and Password
+ </div>
+ </div>
+ <input type="hidden" name="use-facebook" class="use-facebook" value="false" />
+ <input type="hidden" name="use-google" class="use-google" value="false" />
+ <button type="button" class="d-none js-submit-openid">Submit</button>
+ <div class="d-flex gsy gs8 fd-column w50 md:w-auto new-login-right form-item p0">
+ <h3 class="flex--item fs-title">Post as a guest</h3>
+ <div class="flex--item">
+ <div class="d-flex gs4 gsy fd-column">
+ <label class="s-label" for="display-name">Name</label>
+ <div class="d-flex ps-relative">
+ <input class="s-input" id="display-name" name="display-name" maxlength="30" type="text" value="" tabindex="105" placeholder="" />
+ </div>
+ </div>
+ </div>
+ <div class="flex--item">
+ <div class="d-flex gs4 gsy fd-column">
+ <div class="flex--item">
+ <div class="d-flex gs2 gsy fd-column">
+ <label class="flex--item s-label" for="m-address">Email</label>
+ <p class="flex--item s-description">Required, but never shown</p>
+ </div>
+ </div>
+ <div class="d-flex ps-relative">
+ <input class="s-input js-post-email-field" id="m-address" name="m-address" type="text" value="" size="40" tabindex="106" placeholder="" />
+ </div>
+ </div>
+ </div>
+
+ </div>
+ </div>
+ </div>
+ <script>
+ StackExchange.ready(
+ function () {
+ StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f7015668%2fjavascript-closures-and-variable-scope%23new-answer', 'question_page');
+ }
+ );
+ </script>
+ <noscript>
+ <h3 class="flex--item fs-title">Post as a guest</h3>
+ <div class="flex--item">
+ <div class="d-flex gs4 gsy fd-column">
+ <label class="s-label" for="display-name">Name</label>
+ <div class="d-flex ps-relative">
+ <input class="s-input" id="display-name" name="display-name" maxlength="30" type="text" value="" tabindex="105" placeholder="" />
+ </div>
+ </div>
+ </div>
+ <div class="flex--item">
+ <div class="d-flex gs4 gsy fd-column">
+ <div class="flex--item">
+ <div class="d-flex gs2 gsy fd-column">
+ <label class="flex--item s-label" for="m-address">Email</label>
+ <p class="flex--item s-description">Required, but never shown</p>
+ </div>
+ </div>
+ <div class="d-flex ps-relative">
+ <input class="s-input js-post-email-field" id="m-address" name="m-address" type="text" value="" size="40" tabindex="106" placeholder="" />
+ </div>
+ </div>
+ </div>
+
+ </noscript>
+
+ </div>
+
+ <div class="form-submit clear-both d-flex gsx gs4">
+ <button id="submit-button" class="flex--item s-btn s-btn__filled s-btn__icon" type="submit" tabindex="120" autocomplete="off">
+ Post Your Answer
+ </button>
+ <button class="flex--item s-btn s-btn__danger discard-answer dno">
+ Discard
+ </button>
+ <p class="privacy-policy-agreement">
+ By clicking “Post Your Answer”, you agree to our <a href='https://stackoverflow.com/legal/terms-of-service/public' name='tos' target='_blank' class='-link'>terms of service</a> and acknowledge that you have read and understand our <a href='https://stackoverflow.com/legal/privacy-policy' name='privacy' target='_blank' class='-link'>privacy policy</a> and <a href='/conduct' name='conduct' target='_blank' class='-link'>code of conduct</a>.<input type="hidden" name="legalLinksShown" value="1" />
+ </p>
+ </div>
+ <div class="js-general-error general-error clear-both d-none" aria-live="polite"></div>
+ </form>
+
+
+ <h2 class="bottom-notice" data-loc="1">
+ <div>
+Not the answer you&#x27;re looking for? Browse other questions tagged <ul class='ml0 list-ls-none js-post-tag-list-wrapper d-inline'><li class='d-inline mr4 js-post-tag-list-item'><a href="/questions/tagged/javascript" class="post-tag" title="show questions tagged &#39;javascript&#39;" aria-label="show questions tagged &#39;javascript&#39;" rel="tag" aria-labelledby="tag-javascript-tooltip-container">javascript</a></li><li class='d-inline mr4 js-post-tag-list-item'><a href="/questions/tagged/closures" class="post-tag" title="show questions tagged &#39;closures&#39;" aria-label="show questions tagged &#39;closures&#39;" rel="tag" aria-labelledby="tag-closures-tooltip-container">closures</a></li></ul> or <a href="/questions/ask">ask your own question</a>. </div>
+ </h2>
+ </div>
+ </div>
+
+
+<div id="sidebar" class="show-votes" role="complementary" aria-label="sidebar">
+
+
+
+ <div class="s-sidebarwidget s-sidebarwidget__yellow s-anchors s-anchors__grayscale mb16" data-tracker="cb=1">
+ <ul class="d-block p0 m0">
+ <li class="s-sidebarwidget--header s-sidebarwidget__small-bold-text d-flex fc-black-500 d:fc-black-600 bb bbw1">
+ The Overflow Blog
+ </li>
+ <li class="s-sidebarwidget--item d-flex px16">
+ <div class="flex--item1 fl-shrink0">
+<svg aria-hidden="true" class="va-text-top svg-icon iconPencilSm" width="14" height="14" viewBox="0 0 14 14"><path fill="#F1B600" d="m2 10.12 6.37-6.43 1.88 1.88L3.88 12H2v-1.88Z"/><path fill="#E87C87" d="m11.1 1.71 1.13 1.12c.2.2.2.51 0 .71L11.1 4.7 9.21 2.86l1.17-1.15c.2-.2.51-.2.71 0Z"/></svg> </div>
+ <div class="flex--item wmn0 ow-break-word">
+ <a href="https://stackoverflow.blog/2023/12/11/three-types-of-ai-assisted-programmers/" class="js-gps-track" data-ga="[&quot;community bulletin board&quot;,&quot;The Overflow Blog&quot;,&quot;https://stackoverflow.blog/2023/12/11/three-types-of-ai-assisted-programmers/&quot;,null,null]" data-gps-track="communitybulletin.click({ priority: 1, position: 0 })">Three types of AI-assisted programmers</a>
+ </div>
+ </li>
+ <li class="s-sidebarwidget--item d-flex px16">
+ <div class="flex--item1 fl-shrink0">
+<svg aria-hidden="true" class="va-text-top svg-icon iconPencilSm" width="14" height="14" viewBox="0 0 14 14"><path fill="#F1B600" d="m2 10.12 6.37-6.43 1.88 1.88L3.88 12H2v-1.88Z"/><path fill="#E87C87" d="m11.1 1.71 1.13 1.12c.2.2.2.51 0 .71L11.1 4.7 9.21 2.86l1.17-1.15c.2-.2.51-.2.71 0Z"/></svg> </div>
+ <div class="flex--item wmn0 ow-break-word">
+ <a href="https://stackoverflow.blog/2023/12/12/what-gemini-means-for-the-genai-boom/" class="js-gps-track" data-ga="[&quot;community bulletin board&quot;,&quot;The Overflow Blog&quot;,&quot;https://stackoverflow.blog/2023/12/12/what-gemini-means-for-the-genai-boom/&quot;,null,null]" data-gps-track="communitybulletin.click({ priority: 1, position: 1 })">What Gemini means for the GenAI boom</a>
+ </div>
+ </li>
+ <li class="s-sidebarwidget--header s-sidebarwidget__small-bold-text d-flex fc-black-500 d:fc-black-600 bb bbw1">
+ Featured on Meta
+ </li>
+ <li class="s-sidebarwidget--item d-flex px16">
+ <div class="flex--item1 fl-shrink0">
+<div class="favicon favicon-stackexchangemeta" title="Meta Stack Exchange"></div> </div>
+ <div class="flex--item wmn0 ow-break-word">
+ <a href="https://meta.stackexchange.com/questions/395062/seeking-feedback-on-tag-colors-update" class="js-gps-track" data-ga="[&quot;community bulletin board&quot;,&quot;Featured on Meta&quot;,&quot;https://meta.stackexchange.com/questions/395062/seeking-feedback-on-tag-colors-update&quot;,null,null]" data-gps-track="communitybulletin.click({ priority: 3, position: 2 })">Seeking feedback on tag colors update</a>
+ </div>
+ </li>
+ <li class="s-sidebarwidget--item d-flex px16">
+ <div class="flex--item1 fl-shrink0">
+<div class="favicon favicon-stackexchangemeta" title="Meta Stack Exchange"></div> </div>
+ <div class="flex--item wmn0 ow-break-word">
+ <a href="https://meta.stackexchange.com/questions/395389/update-to-our-advertising-guidelines" class="js-gps-track" data-ga="[&quot;community bulletin board&quot;,&quot;Featured on Meta&quot;,&quot;https://meta.stackexchange.com/questions/395389/update-to-our-advertising-guidelines&quot;,null,null]" data-gps-track="communitybulletin.click({ priority: 3, position: 3 })">Update to our Advertising Guidelines</a>
+ </div>
+ </li>
+ <li class="s-sidebarwidget--item d-flex px16">
+ <div class="flex--item1 fl-shrink0">
+<div class="favicon favicon-stackoverflowmeta" title="Meta Stack Overflow"></div> </div>
+ <div class="flex--item wmn0 ow-break-word">
+ <a href="https://meta.stackoverflow.com/questions/427199/collectives-updates-new-features-and-ways-to-get-started-with-discussions" class="js-gps-track" data-ga="[&quot;community bulletin board&quot;,&quot;Featured on Meta&quot;,&quot;https://meta.stackoverflow.com/questions/427199/collectives-updates-new-features-and-ways-to-get-started-with-discussions&quot;,null,null]" data-gps-track="communitybulletin.click({ priority: 6, position: 4 })">Collectives updates: new features and ways to get started with Discussions</a>
+ </div>
+ </li>
+ <li class="s-sidebarwidget--item d-flex px16">
+ <div class="flex--item1 fl-shrink0">
+<div class="favicon favicon-stackoverflowmeta" title="Meta Stack Overflow"></div> </div>
+ <div class="flex--item wmn0 ow-break-word">
+ <a href="https://meta.stackoverflow.com/questions/427335/overflowai-alpha-invitation-emails-were-distributed-in-error-nov-28th" class="js-gps-track" data-ga="[&quot;community bulletin board&quot;,&quot;Featured on Meta&quot;,&quot;https://meta.stackoverflow.com/questions/427335/overflowai-alpha-invitation-emails-were-distributed-in-error-nov-28th&quot;,null,null]" data-gps-track="communitybulletin.click({ priority: 6, position: 5 })">OverflowAI Alpha invitation emails were distributed in error Nov 28th</a>
+ </div>
+ </li>
+ <li class="s-sidebarwidget--item d-flex px16">
+ <div class="flex--item1 fl-shrink0">
+<div class="favicon favicon-stackoverflowmeta" title="Meta Stack Overflow"></div> </div>
+ <div class="flex--item wmn0 ow-break-word">
+ <a href="https://meta.stackoverflow.com/questions/421831/temporary-policy-generative-ai-e-g-chatgpt-is-banned" class="js-gps-track" data-ga="[&quot;community bulletin board&quot;,&quot;Featured on Meta&quot;,&quot;https://meta.stackoverflow.com/questions/421831/temporary-policy-generative-ai-e-g-chatgpt-is-banned&quot;,null,null]" data-gps-track="communitybulletin.click({ priority: 6, position: 6 })">Temporary policy: Generative AI (e.g., ChatGPT) is banned</a>
+ </div>
+ </li>
+ </ul>
+ </div>
+
+
+<div class="js-zone-container zone-container-sidebar">
+ <div id="dfp-tsb" class="everyonelovesstackoverflow everyoneloves__top-sidebar"></div>
+ <div class="js-report-ad-button-container " style="width: 300px"></div>
+</div>
+<div class="js-zone-container zone-container-sidebar">
+ <div id="dfp-msb" class="everyonelovesstackoverflow everyoneloves__mid-sidebar"></div>
+ <div class="js-report-ad-button-container " style="width: 300px"></div>
+</div>
+<div id="hireme"></div> <div class="module sidebar-linked">
+ <h4 id="h-linked">Linked</h4>
+ <div class="linked" data-tracker="lq=1">
+ <div class="spacer js-gps-track" data-gps-track="linkedquestion.click({ source_post_id: 7015668, target_question_id: 7002642, position: 0 })">
+ <a href="/q/7002642" title="Question score (upvotes - downvotes)">
+ <div class="answer-votes answered-accepted default">2</div>
+ </a>
+ <a href="/questions/7002642/javascript-variable-scope-in-event-handler?noredirect=1" class="question-hyperlink">Javascript - variable scope in event handler</a>
+ </div>
+ </div>
+</div>
+
+
+
+
+
+ <div class="module sidebar-related">
+ <h4 id="h-related">Related</h4>
+ <div class="related js-gps-related-questions" data-tracker="rq=3">
+ <div class="spacer" data-question-id="111102">
+ <a href="/q/111102" title="Question score (upvotes - downvotes)" >
+ <div class="answer-votes answered-accepted extra-large">7619</div>
+ </a>
+ <a href="/questions/111102/how-do-javascript-closures-work" class="question-hyperlink">How do JavaScript closures work?</a>
+ </div>
+ <div class="spacer" data-question-id="631187">
+ <a href="/q/631187" title="Question score (upvotes - downvotes)" >
+ <div class="answer-votes answered-accepted default">14</div>
+ </a>
+ <a href="/questions/631187/javascript-scope-and-closure" class="question-hyperlink">JavaScript scope and closure</a>
+ </div>
+ <div class="spacer" data-question-id="7322062">
+ <a href="/q/7322062" title="Question score (upvotes - downvotes)" >
+ <div class="answer-votes answered-accepted default">3</div>
+ </a>
+ <a href="/questions/7322062/closure-in-javascript" class="question-hyperlink">closure in JavaScript</a>
+ </div>
+ <div class="spacer" data-question-id="15794410">
+ <a href="/q/15794410" title="Question score (upvotes - downvotes)" >
+ <div class="answer-votes answered-accepted default">0</div>
+ </a>
+ <a href="/questions/15794410/javascript-closure-and-its-scope" class="question-hyperlink">Javascript closure and its scope</a>
+ </div>
+ <div class="spacer" data-question-id="20865479">
+ <a href="/q/20865479" title="Question score (upvotes - downvotes)" >
+ <div class="answer-votes answered-accepted default">1</div>
+ </a>
+ <a href="/questions/20865479/variable-scope-in-closure" class="question-hyperlink">Variable Scope in Closure</a>
+ </div>
+ <div class="spacer" data-question-id="21051039">
+ <a href="/q/21051039" title="Question score (upvotes - downvotes)" >
+ <div class="answer-votes answered-accepted default">1</div>
+ </a>
+ <a href="/questions/21051039/javascript-closure-confusion" class="question-hyperlink">Javascript closure confusion</a>
+ </div>
+ <div class="spacer" data-question-id="37824806">
+ <a href="/q/37824806" title="Question score (upvotes - downvotes)" >
+ <div class="answer-votes answered-accepted default">0</div>
+ </a>
+ <a href="/questions/37824806/javascript-closure-scope-confusion" class="question-hyperlink">Javascript closure scope confusion</a>
+ </div>
+ <div class="spacer" data-question-id="41986230">
+ <a href="/q/41986230" title="Question score (upvotes - downvotes)" >
+ <div class="answer-votes default">1</div>
+ </a>
+ <a href="/questions/41986230/javascript-closure-and-scope" class="question-hyperlink">JavaScript closure and scope</a>
+ </div>
+ <div class="spacer" data-question-id="49581863">
+ <a href="/q/49581863" title="Question score (upvotes - downvotes)" >
+ <div class="answer-votes default">0</div>
+ </a>
+ <a href="/questions/49581863/javascript-closure-scope" class="question-hyperlink">Javascript Closure / Scope</a>
+ </div>
+ <div class="spacer" data-question-id="67304272">
+ <a href="/q/67304272" title="Question score (upvotes - downvotes)" >
+ <div class="answer-votes default">0</div>
+ </a>
+ <a href="/questions/67304272/javascript-closures-and-variables" class="question-hyperlink">Javascript closures and variables</a>
+ </div>
+ </div>
+ </div>
+ <script type="text/javascript">
+ $(document).ready(function() {
+ $(".js-gps-related-questions .spacer").click(function () {
+ fireRelatedEvent($(this).index() + 1, $(this).data('question-id'));
+ });
+
+ function fireRelatedEvent(position, questionId) {
+ StackExchange.using("gps", function() {
+ StackExchange.gps.track('related_questions.click',
+ {
+ position: position,
+ originQuestionId: 7015668,
+ relatedQuestionId: +questionId,
+ location: 'sidebar',
+ source: 'Baseline'
+ });
+ });
+ }
+ });
+ </script>
+
+
+
+ <div id="hot-network-questions" class="module tex2jax_ignore">
+ <h4>
+ <a href="https://stackexchange.com/questions?tab=hot"
+ class="js-gps-track s-link s-link__inherit"
+ data-gps-track="posts_hot_network.click({ item_type:1, location:11 })">
+ Hot Network Questions
+ </a>
+ </h4>
+ <ul>
+ <li >
+ <div class="favicon favicon-hermeneutics" title="Biblical Hermeneutics Stack Exchange"></div><a href="https://hermeneutics.stackexchange.com/questions/89460/1-chronicles-21-1-2-davids-numbering-of-israel-is-it-a-sin" class="js-gps-track question-hyperlink mb0" data-gps-track="site.switch({ item_type:11, target_site:320 }); posts_hot_network.click({ item_type:2, location:11 })">
+ 1 Chronicles 21, 1-2: David&#x27;s numbering of Israel: is it a sin?
+ </a>
+
+ </li>
+ <li >
+ <div class="favicon favicon-mattermodeling" title="Matter Modeling Stack Exchange"></div><a href="https://mattermodeling.stackexchange.com/questions/12067/total-energy-calculation-for-an-isolated-atom" class="js-gps-track question-hyperlink mb0" data-gps-track="site.switch({ item_type:11, target_site:704 }); posts_hot_network.click({ item_type:2, location:11 })">
+ Total energy calculation for an isolated atom
+ </a>
+
+ </li>
+ <li >
+ <div class="favicon favicon-space" title="Space Exploration Stack Exchange"></div><a href="https://space.stackexchange.com/questions/64995/can-a-meteor-shower-have-a-period-of-less-than-1-year" class="js-gps-track question-hyperlink mb0" data-gps-track="site.switch({ item_type:11, target_site:508 }); posts_hot_network.click({ item_type:2, location:11 })">
+ Can a meteor shower have a period of less than 1 year?
+ </a>
+
+ </li>
+ <li >
+ <div class="favicon favicon-codereview" title="Code Review Stack Exchange"></div><a href="https://codereview.stackexchange.com/questions/288401/dynamic-array-of-int-in-c" class="js-gps-track question-hyperlink mb0" data-gps-track="site.switch({ item_type:11, target_site:196 }); posts_hot_network.click({ item_type:2, location:11 })">
+ Dynamic array of int in C
+ </a>
+
+ </li>
+ <li >
+ <div class="favicon favicon-law" title="Law Stack Exchange"></div><a href="https://law.stackexchange.com/questions/97918/can-a-corporation-refuse-to-know-things-its-agents-know" class="js-gps-track question-hyperlink mb0" data-gps-track="site.switch({ item_type:11, target_site:617 }); posts_hot_network.click({ item_type:2, location:11 })">
+ Can a corporation refuse to know things its agents know?
+ </a>
+
+ </li>
+ <li class="dno js-hidden">
+ <div class="favicon favicon-english" title="English Language &amp; Usage Stack Exchange"></div><a href="https://english.stackexchange.com/questions/615737/is-there-a-difference-between-there-is-a-noun-vs-a-noun-is-there" class="js-gps-track question-hyperlink mb0" data-gps-track="site.switch({ item_type:11, target_site:97 }); posts_hot_network.click({ item_type:2, location:11 })">
+ Is there a difference between &quot;There is a [noun]&quot; vs &quot;A [noun] is there&quot;?
+ </a>
+
+ </li>
+ <li class="dno js-hidden">
+ <div class="favicon favicon-astronomy" title="Astronomy Stack Exchange"></div><a href="https://astronomy.stackexchange.com/questions/55521/how-did-the-ancient-greeks-measure-celestial-angles" class="js-gps-track question-hyperlink mb0" data-gps-track="site.switch({ item_type:11, target_site:514 }); posts_hot_network.click({ item_type:2, location:11 })">
+ How did the ancient Greeks measure celestial angles?
+ </a>
+
+ </li>
+ <li class="dno js-hidden">
+ <div class="favicon favicon-stats" title="Cross Validated"></div><a href="https://stats.stackexchange.com/questions/634815/probability-of-a-head-in-a-particular-trial-with-binomial-distribution" class="js-gps-track question-hyperlink mb0" data-gps-track="site.switch({ item_type:11, target_site:65 }); posts_hot_network.click({ item_type:2, location:11 })">
+ Probability of a head in a particular trial with binomial distribution
+ </a>
+
+ </li>
+ <li class="dno js-hidden">
+ <div class="favicon favicon-astronomy" title="Astronomy Stack Exchange"></div><a href="https://astronomy.stackexchange.com/questions/55513/what-star-is-this" class="js-gps-track question-hyperlink mb0" data-gps-track="site.switch({ item_type:11, target_site:514 }); posts_hot_network.click({ item_type:2, location:11 })">
+ What star is this?
+ </a>
+
+ </li>
+ <li class="dno js-hidden">
+ <div class="favicon favicon-hermeneutics" title="Biblical Hermeneutics Stack Exchange"></div><a href="https://hermeneutics.stackexchange.com/questions/89498/does-the-apostles-convey-something-different-than-apostles-in-the-new-testam" class="js-gps-track question-hyperlink mb0" data-gps-track="site.switch({ item_type:11, target_site:320 }); posts_hot_network.click({ item_type:2, location:11 })">
+ Does &quot;the apostles&quot; convey something different than &quot;apostles&quot; in the New Testament?
+ </a>
+
+ </li>
+ <li class="dno js-hidden">
+ <div class="favicon favicon-mathematica" title="Mathematica Stack Exchange"></div><a href="https://mathematica.stackexchange.com/questions/295033/highlight-a-time-range-in-a-datelistplot" class="js-gps-track question-hyperlink mb0" data-gps-track="site.switch({ item_type:11, target_site:387 }); posts_hot_network.click({ item_type:2, location:11 })">
+ Highlight a time range in a DateListPlot
+ </a>
+
+ </li>
+ <li class="dno js-hidden">
+ <div class="favicon favicon-worldbuilding" title="Worldbuilding Stack Exchange"></div><a href="https://worldbuilding.stackexchange.com/questions/251907/what-coordinates-on-earth-would-provide-the-most-arable-land-for-a-large-island" class="js-gps-track question-hyperlink mb0" data-gps-track="site.switch({ item_type:11, target_site:579 }); posts_hot_network.click({ item_type:2, location:11 })">
+ What coordinates on Earth would provide the most arable land for a large island?
+ </a>
+
+ </li>
+ <li class="dno js-hidden">
+ <div class="favicon favicon-softwareengineering" title="Software Engineering Stack Exchange"></div><a href="https://softwareengineering.stackexchange.com/questions/450101/password-reset-email-that-is-not-considered-spam" class="js-gps-track question-hyperlink mb0" data-gps-track="site.switch({ item_type:11, target_site:131 }); posts_hot_network.click({ item_type:2, location:11 })">
+ Password reset email that is not considered spam
+ </a>
+
+ </li>
+ <li class="dno js-hidden">
+ <div class="favicon favicon-hsm" title="History of Science and Mathematics Stack Exchange"></div><a href="https://hsm.stackexchange.com/questions/16017/demorgans-commentary-on-euclids-elements" class="js-gps-track question-hyperlink mb0" data-gps-track="site.switch({ item_type:11, target_site:587 }); posts_hot_network.click({ item_type:2, location:11 })">
+ DeMorgan&#x27;s commentary on Euclid&#x27;s Elements
+ </a>
+
+ </li>
+ <li class="dno js-hidden">
+ <div class="favicon favicon-scifi" title="Science Fiction &amp; Fantasy Stack Exchange"></div><a href="https://scifi.stackexchange.com/questions/281703/book-last-read-in-2000-involving-a-boy-named-zeek-i-think-who-was-training-to-be" class="js-gps-track question-hyperlink mb0" data-gps-track="site.switch({ item_type:11, target_site:186 }); posts_hot_network.click({ item_type:2, location:11 })">
+ Book last read in 2000 involving a boy named Zeek I think who was training to be a wizard and visits a dimension called the bazaar
+ </a>
+
+ </li>
+ <li class="dno js-hidden">
+ <div class="favicon favicon-blender" title="Blender Stack Exchange"></div><a href="https://blender.stackexchange.com/questions/307879/baloon-pop-animation" class="js-gps-track question-hyperlink mb0" data-gps-track="site.switch({ item_type:11, target_site:502 }); posts_hot_network.click({ item_type:2, location:11 })">
+ Baloon Pop Animation
+ </a>
+
+ </li>
+ <li class="dno js-hidden">
+ <div class="favicon favicon-tex" title="TeX - LaTeX Stack Exchange"></div><a href="https://tex.stackexchange.com/questions/704910/draw-saccharides" class="js-gps-track question-hyperlink mb0" data-gps-track="site.switch({ item_type:11, target_site:85 }); posts_hot_network.click({ item_type:2, location:11 })">
+ Draw saccharides
+ </a>
+
+ </li>
+ <li class="dno js-hidden">
+ <div class="favicon favicon-politics" title="Politics Stack Exchange"></div><a href="https://politics.stackexchange.com/questions/83202/is-there-a-precedent-for-a-western-european-country-expelling-u-s-diplomats-ove" class="js-gps-track question-hyperlink mb0" data-gps-track="site.switch({ item_type:11, target_site:475 }); posts_hot_network.click({ item_type:2, location:11 })">
+ Is there a precedent for a Western European country expelling U.S. diplomats over spying?
+ </a>
+
+ </li>
+ <li class="dno js-hidden">
+ <div class="favicon favicon-german" title="German Language Stack Exchange"></div><a href="https://german.stackexchange.com/questions/75997/what-are-cases-used-for" class="js-gps-track question-hyperlink mb0" data-gps-track="site.switch({ item_type:11, target_site:253 }); posts_hot_network.click({ item_type:2, location:11 })">
+ What are cases used for?
+ </a>
+
+ </li>
+ <li class="dno js-hidden">
+ <div class="favicon favicon-movies" title="Movies &amp; TV Stack Exchange"></div><a href="https://movies.stackexchange.com/questions/121628/what-is-the-significance-of-the-plane-tickets-in-home-alone" class="js-gps-track question-hyperlink mb0" data-gps-track="site.switch({ item_type:11, target_site:367 }); posts_hot_network.click({ item_type:2, location:11 })">
+ What is the significance of the plane tickets in Home Alone?
+ </a>
+
+ </li>
+ <li class="dno js-hidden">
+ <div class="favicon favicon-mechanics" title="Motor Vehicle Maintenance &amp; Repair Stack Exchange"></div><a href="https://mechanics.stackexchange.com/questions/94659/engine-comparison-how-can-a-smaller-more-efficient-engine-excel-over-its-bigge" class="js-gps-track question-hyperlink mb0" data-gps-track="site.switch({ item_type:11, target_site:224 }); posts_hot_network.click({ item_type:2, location:11 })">
+ Engine comparison: How can a smaller/more efficient engine excel over its &quot;bigger sibling&quot;?
+ </a>
+
+ </li>
+ <li class="dno js-hidden">
+ <div class="favicon favicon-history" title="History Stack Exchange"></div><a href="https://history.stackexchange.com/questions/72953/is-this-apparent-story-about-how-julius-caesar-selected-soldiers-true" class="js-gps-track question-hyperlink mb0" data-gps-track="site.switch({ item_type:11, target_site:324 }); posts_hot_network.click({ item_type:2, location:11 })">
+ Is this apparent story about how Julius Caesar selected soldiers true?
+ </a>
+
+ </li>
+ <li class="dno js-hidden">
+ <div class="favicon favicon-physics" title="Physics Stack Exchange"></div><a href="https://physics.stackexchange.com/questions/793345/why-is-the-centre-of-mass-useful-in-a-discrete-particle-system" class="js-gps-track question-hyperlink mb0" data-gps-track="site.switch({ item_type:11, target_site:151 }); posts_hot_network.click({ item_type:2, location:11 })">
+ Why is the centre of mass useful in a discrete particle system?
+ </a>
+
+ </li>
+ <li class="dno js-hidden">
+ <div class="favicon favicon-money" title="Personal Finance &amp; Money Stack Exchange"></div><a href="https://money.stackexchange.com/questions/159552/0-apr-promotional-offer-for-credit-cards" class="js-gps-track question-hyperlink mb0" data-gps-track="site.switch({ item_type:11, target_site:93 }); posts_hot_network.click({ item_type:2, location:11 })">
+ 0 APR Promotional Offer For Credit Cards
+ </a>
+
+ </li>
+ </ul>
+
+ <a href="#"
+ class="show-more js-show-more js-gps-track"
+ data-gps-track="posts_hot_network.click({ item_type:3, location:11 })">
+ more hot questions
+ </a>
+</div>
+
+ <div id="feed-link" class="js-feed-link">
+ <a href="/feeds/question/7015668" title="Feed of this question and its answers">
+ <svg aria-hidden="true" class="fc-orange-400 svg-icon iconRss" width="18" height="18" viewBox="0 0 18 18"><path d="M3 1a2 2 0 0 0-2 2v12c0 1.1.9 2 2 2h12a2 2 0 0 0 2-2V3a2 2 0 0 0-2-2H3Zm0 1.5c6.9 0 12.5 5.6 12.5 12.5H13C13 9.55 8.45 5 3 5V2.5Zm0 5c4.08 0 7.5 3.41 7.5 7.5H8c0-2.72-2.28-5-5-5V7.5Zm0 5c1.36 0 2.5 1.14 2.5 2.5H3v-2.5Z"/></svg>
+ Question feed
+ </a>
+ </div>
+ <aside class="s-modal js-feed-link-modal" tabindex="-1" role="dialog" aria-labelledby="feed-modal-title" aria-describedby="feed-modal-description" aria-hidden="true">
+ <div class="s-modal--dialog js-modal-dialog wmx4" role="document" data-controller="se-draggable">
+ <h1 class="s-modal--header fw-bold js-first-tabbable" id="feed-modal-title" data-se-draggable-target="handle" tabindex="0">
+ Subscribe to RSS
+ </h1>
+ <div class="d-flex gs4 gsy fd-column">
+ <div class="flex--item">
+ <label class="d-block s-label c-default" for="feed-url">
+ Question feed
+ <p class="s-description mt2" id="feed-modal-description">To subscribe to this RSS feed, copy and paste this URL into your RSS reader.</p>
+ </label>
+ </div>
+ <div class="d-flex ps-relative">
+ <input class="s-input" type="text" name="feed-url" id="feed-url" readonly="readonly" value="https://stackoverflow.com/feeds/question/7015668" />
+ <svg aria-hidden="true" class="s-input-icon fc-orange-400 svg-icon iconRss" width="18" height="18" viewBox="0 0 18 18"><path d="M3 1a2 2 0 0 0-2 2v12c0 1.1.9 2 2 2h12a2 2 0 0 0 2-2V3a2 2 0 0 0-2-2H3Zm0 1.5c6.9 0 12.5 5.6 12.5 12.5H13C13 9.55 8.45 5 3 5V2.5Zm0 5c4.08 0 7.5 3.41 7.5 7.5H8c0-2.72-2.28-5-5-5V7.5Zm0 5c1.36 0 2.5 1.14 2.5 2.5H3v-2.5Z"/></svg>
+ </div>
+ </div>
+ <a class="s-modal--close s-btn s-btn__muted js-modal-close js-last-tabbable" href="#" aria-label="Close">
+ <svg aria-hidden="true" class="svg-icon iconClearSm" width="14" height="14" viewBox="0 0 14 14"><path d="M12 3.41 10.59 2 7 5.59 3.41 2 2 3.41 5.59 7 2 10.59 3.41 12 7 8.41 10.59 12 12 10.59 8.41 7 12 3.41Z"/></svg>
+ </a>
+ </div>
+ </aside>
+
+</div>
+
+ </div>
+<script>StackExchange.ready(function(){$.get('/posts/7015668/ivc/5203?prg=bab78ed4-13b3-4721-9c4f-9a5712f44cbd');});</script>
+<noscript><div><img src="/posts/7015668/ivc/5203?prg=bab78ed4-13b3-4721-9c4f-9a5712f44cbd" class="dno" alt="" width="0" height="0"></div></noscript><div style="display:none" id="js-codeblock-lang">lang-js</div></div>
+
+
+
+ </div>
+ </div>
+
+
+ <script type="text/javascript">
+ var cam = cam || { opt: {} };
+ var clcGamLoaderOptions = cam || { opt: {} };
+ var opt = clcGamLoaderOptions.opt;
+
+ opt.omni = 'BwoLCLDo3cfgr748EAUY9JmsAyACKAI6FXxqYXZhc2NyaXB0fGNsb3N1cmVzfEAASADQ_RcyU13wgTG-';
+ opt.refresh = !1;
+ opt.refreshInterval = 90;
+ opt.sf = !0;
+ opt.hb = !1;
+ opt.ll = !0;
+ opt.tlb_position = 0;
+ opt.personalization_consent = !1;
+ opt.targeting_consent = !1;
+ opt.performance_consent = !1;
+
+ opt.targeting = {Registered:['false'],'so-tag':['javascript','closures'],'tag-reportable':['javascript','closures'],NumberOfAnswers:['2']};
+ opt.adReportEnabled = !0;
+ opt.adReportUrl = '/ads/report-ad';
+ opt.adReportText = 'Report this ad';
+ opt.adReportFileTypeErrorMessage = 'Please select a PNG or JPG file.';
+ opt.adReportFileSizeErrorMessage = 'The file must be under 2 MiB.';
+ opt.adReportErrorText = 'Error uploading ad report.';
+ opt.adReportThanksText = 'Thanks for your feedback. We’ll review this against our code of conduct and take action if necessary.';
+ opt.adReportLoginExpiredMessage = 'Your login session has expired, please login and try again.';
+ opt.adReportLoginErrorMessage = 'An error occurred when loading the report form - please try again';
+ opt.adReportModalClass = 'js-ad-report';
+ opt.perRequestGuid = 'bab78ed4-13b3-4721-9c4f-9a5712f44cbd';
+ opt.responseHash = '0y0/6RE3LLR0TPiQiNNUsNfrZhiXmhK3bkt/9KbW6so=';
+
+
+ opt.targeting.TargetingConsent = ['False_Active'];
+ opt.allowAccountTargetingForThisRequest = !1;
+
+ const urlParams = new URLSearchParams(window.location.search);
+ if (urlParams.has('dfptestads')) {
+ const dfptestads = urlParams.get('dfptestads');
+ opt.targeting.DfpTestAds = dfptestads;
+ }
+</script>
+<script>;(()=>{"use strict";var __webpack_modules__={23:(e,t,s)=>{s.d(t,{Z7:()=>d,eq:()=>a,kG:()=>r});const n=/^\/tags\//.test(location.pathname)||/^\/questions\/tagged\//.test(location.pathname)?"tag-pages":/^\/$/.test(location.pathname)||/^\/home/.test(location.pathname)?"home-page":"question-pages";let o=location.hostname;const i={slots:{lb:[[728,90]],mlb:[[728,90]],smlb:[[728,90]],bmlb:[[728,90]],sb:e=>"dfp-tsb"===e?[[300,250],[300,600]]:[[300,250]],"tag-sponsorship":[[730,135]],"mobile-below-question":[[320,50],[300,250]],msb:[[300,250],[300,600]],"talent-conversion-tracking":[[1,1]],"site-sponsorship":[[230,60]]},ids:{"dfp-tlb":"lb","dfp-mlb":"mlb","dfp-smlb":"smlb","dfp-bmlb":"bmlb","dfp-tsb":"sb","dfp-isb":"sb","dfp-tag":"tag-sponsorship","dfp-msb":"msb","dfp-sspon":"site-sponsorship","dfp-m-aq":"mobile-below-question"},idsToExcludeFromAdReports:["dfp-sspon"]};function r(){return Object.keys(i.ids)}function a(e){return i.idsToExcludeFromAdReports.indexOf(e)<0}function d(e){var t=e.split("_")[0];const s=i.ids[t];let r=i.slots[s];return"function"==typeof r&&(r=r(t)),{path:`/248424177/${o}/${s}/${n}`,sizes:r,zone:s}}},865:(e,t,s)=>{function n(e){return"string"==typeof e?document.getElementById(e):e}function o(e){return!!(e=n(e))&&"none"===getComputedStyle(e).display}function i(e){return!o(e)}function r(e){return!!e}function a(e){return/^\s*$/.test(n(e).innerHTML)}function d(e){const{style:t}=e;t.height=t.maxHeight=t.minHeight="auto",t.display="none"}function l(e){const{style:t}=e;t.height=t.maxHeight=t.minHeight="auto",t.display="none",[].forEach.call(e.children,l)}function c(e){const{style:t}=e;t.height=t.maxHeight=t.minHeight="auto",t.removeProperty("display")}function g(e){const t=document.createElement("script");t.src=e,document.body.appendChild(t)}function p(e){return s=e,(t=[]).push=function(e){return s(),delete this.push,this.push(e)},t;var t,s}function h(e){let t="function"==typeof HTMLTemplateElement;var s=document.createElement(t?"template":"div");return e=e.trim(),s.innerHTML=e,t?s.content.firstChild:s.firstChild}s.d(t,{$Z:()=>c,Bv:()=>h,Gx:()=>g,Nj:()=>n,QZ:()=>p,cf:()=>d,pn:()=>i,wo:()=>l,xb:()=>a,xj:()=>o,yb:()=>r})},763:(__unused_webpack_module,__webpack_exports__,__webpack_require__)=>{__webpack_require__.d(__webpack_exports__,{t:()=>AdReports});var _common_helper__WEBPACK_IMPORTED_MODULE_2__=__webpack_require__(865),_console__WEBPACK_IMPORTED_MODULE_1__=__webpack_require__(276),_ad_units__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__(23);class AdReports{constructor(e,t){if(this.googletag=e,this.cam=t,this.allowedFileTypes=["image/png","image/jpg","image/jpeg"],this.ignoreValidation=!1,_console__WEBPACK_IMPORTED_MODULE_1__.cM("Ad reporting init"),this.cam=t,this.callOnButtonClick=e=>this.onButtonClick(e),this.googletag.pubads().addEventListener("slotRenderEnded",e=>this.handleSlotRendered(e)),Array.isArray(t.slotsRenderedEvents)){_console__WEBPACK_IMPORTED_MODULE_1__.cM("Adding report button to "+t.slotsRenderedEvents.length+" events that have transpired");for(var s=0;s<t.slotsRenderedEvents.length;s++)this.handleSlotRendered(t.slotsRenderedEvents[s])}}handleSlotRendered(e){if(e&&e.slot&&!e.isEmpty&&(e.creativeId||e.lineItemId||!e.isEmpty)){var t=e.slot.getSlotElementId();if(t){var s=document.getElementById(t);if(s)if((0,_ad_units__WEBPACK_IMPORTED_MODULE_0__.eq)(t)){var n=s?.closest(".js-zone-container")?.querySelector(".js-report-ad-button-container");n.innerHTML="",n.append(this.createButton(e)),n.style.height="24px",_console__WEBPACK_IMPORTED_MODULE_1__.cM("Added report button to the bottom of "+t)}else _console__WEBPACK_IMPORTED_MODULE_1__.cM("Not adding report button to the bottom of "+t+": shouldHaveReportButton = false");else _console__WEBPACK_IMPORTED_MODULE_1__.cM("Not adding report button to the bottom of "+t+": resolved invalid adUnit element")}else _console__WEBPACK_IMPORTED_MODULE_1__.cM("Not adding report button to the bottom of element: invalid adUnitElementId")}else _console__WEBPACK_IMPORTED_MODULE_1__.cM("Not adding report button to the bottom of element: invalid SlotRenderEndedEvent")}async onButtonClick(e){e.preventDefault();let t=e.target;const s=t.dataset.modalUrl,n=t.dataset.googleEventData;return await this.loadModal(s,t,n),!1}createButton(e){let t=document.createElement("button");var s=JSON.stringify(e);return t.dataset.googleEventData=s,t.dataset.modalUrl=this.cam.opt.adReportUrl,t.dataset.adUnit=e.slot.getSlotElementId(),t.classList.add("js-report-ad","s-btn","s-btn__link","fs-fine","mt2","float-right"),t.append(document.createTextNode(this.cam.opt.adReportText)),t.removeEventListener("click",this.callOnButtonClick),t.addEventListener("click",this.callOnButtonClick),t}async loadModal(url,$link,googleEventData){try{await window.StackExchange.helpers.loadModal(url,{returnElements:window.$($link)}),this.initForm(googleEventData)}catch(e){var message="",response=e.responseText?eval(`(${e.responseText})`):null;message=response&&response.isLoggedOut?this.cam.opt.adReportLoginExpiredMessage:this.cam.opt.adReportLoginErrorMessage,window.StackExchange.helpers.showToast(message,{type:"danger"})}}removeModal(){window.StackExchange.helpers.closePopups(document.querySelectorAll("."+this.cam.opt.adReportModalClass),"dismiss")}initForm(e,t=!1){this.ignoreValidation=t,this.$form=document.querySelector(".js-ad-report-form"),this.$googleEventData=this.$form.querySelector(".js-json-data"),this.$adReportReasons=this.$form.querySelectorAll(".js-ad-report-reason"),this.$adReportReasonOther=this.$form.querySelector(".js-ad-report-reason-other"),this.$fileUploaderInput=this.$form.querySelector(".js-file-uploader-input"),this.$imageUploader=this.$form.querySelector(".js-image-uploader"),this.$clearImageUpload=this.$form.querySelector(".js-clear-image-upload"),this.$imageUploaderText=this.$form.querySelector(".js-image-uploader-text"),this.$imageUploaderPreview=this.$form.querySelector(".js-image-uploader-preview"),this.$fileErrorMessage=this.$form.querySelector(".js-file-error");const s=this.$form.querySelector(".js-drag-drop-enabled"),n=this.$form.querySelector(".js-drag-drop-disabled");this.$googleEventData.value=e,this.$adReportReasons.forEach((e,t)=>e.addEventListener("change",e=>{this.$adReportReasonOther.classList.toggle("d-none","3"!==e.target.value)})),this.$fileUploaderInput.addEventListener("change",()=>{this.validateFileInput()&&this.updateImagePreview(this.$fileUploaderInput.files)}),this.$clearImageUpload.addEventListener("click",e=>{e.preventDefault(),this.clearImageUpload()});try{this.$fileUploaderInput[0].value="",this.$imageUploader.addEventListener("dragenter dragover dragleave drop",this.preventDefaults),this.$imageUploader.addEventListener("dragenter dragover",this.handleDragStart),this.$imageUploader.addEventListener("dragleave drop",this.handleDragEnd),this.$imageUploader.addEventListener("drop",this.handleDrop)}catch(e){s.classList.add("d-none"),n.classList.remove("d-none")}this.$form.removeEventListener("",this.handleDragEnd),this.$form.addEventListener("submit",async e=>(e.preventDefault(),this.submitForm(),!1))}clearImageUpload(){this.$fileUploaderInput.value="",this.$imageUploaderPreview.setAttribute("src",""),this.$imageUploaderPreview.classList.add("d-none"),this.$clearImageUpload.classList.add("d-none"),this.$imageUploaderText.classList.remove("d-none"),this.$imageUploader.classList.add("p16","ba","bas-dashed","bc-black-100")}preventDefaults(e){e.preventDefault(),e.stopPropagation()}handleDragStart(e){this.$imageUploader.classList.remove("bas-dashed"),this.$imageUploader.classList.add("bas-solid","bc-black-100")}handleDragEnd(e){this.$imageUploader.classList.remove("bas-solid","bc-black-100"),this.$imageUploader.classList.add("bas-dashed")}handleDrop(e){var t=e.originalEvent.dataTransfer.files;FileReader&&t&&1===t.length&&(this.$fileUploaderInput.files=t,this.validateFileInput()&&this.updateImagePreview(t))}setError(e){this.$fileErrorMessage.parentElement.classList.toggle("has-error",e)}updateImagePreview(e){this.$imageUploader.classList.remove("p16","ba","bas-dashed","bc-black-100"),this.$clearImageUpload.classList.remove("d-none"),this.$imageUploaderText.classList.add("d-none");var t=new FileReader;t.onload=e=>{null!=e.target&&(this.$imageUploaderPreview.setAttribute("src",e.target.result),this.$imageUploaderPreview.classList.remove("d-none"))},t.readAsDataURL(e[0])}validateFileInput(){if(this.ignoreValidation)return!0;const e=this.cam.opt.adReportFileTypeErrorMessage,t=this.cam.opt.adReportFileSizeErrorMessage;if(null==this.$fileUploaderInput.files)return!1;var s=this.$fileUploaderInput.files[0];return null==s?(this.setError(!0),!1):this.allowedFileTypes.indexOf(s.type)<0?(this.$fileErrorMessage.textContent=e,this.$fileErrorMessage.classList.remove("d-none"),this.setError(!0),!1):s.size>2097152?(this.$fileErrorMessage.textContent=t,this.$fileErrorMessage.classList.remove("d-none"),this.setError(!0),!1):(this.$fileErrorMessage.classList.add("d-none"),this.setError(!1),!0)}async gatherDiagnosticInfo(){return{BrowserVersion:await this.getBrowserVersion()}}getElementSource(e){return e.outerHTML}getNestedIFrameElement(e){var t=e.querySelector("iframe");return t.contentDocument?t.contentDocument.documentElement:t.contentWindow.document.documentElement}async getBrowserVersion(){return await navigator.userAgentData.getHighEntropyValues(["fullVersionList"]).then(e=>JSON.stringify(e.fullVersionList))}async submitForm(){if(!this.validateFileInput())return!1;this.$form.querySelector("[type=submit]").setAttribute("disabled","true");var e=JSON.parse(this.$googleEventData.value||"{}");e.Reason=parseInt(this.$form.querySelector(".js-ad-report-reason:checked").value,10),e.Description=this.$adReportReasonOther.value,this.$googleEventData.value=JSON.stringify(e);var t=new FormData(this.$form);if("1"===t.get("shareDiagnosticInfo")){var s=await this.gatherDiagnosticInfo();Object.keys(s).forEach(e=>t.append(e,s[e]))}try{const e=await window.fetch(this.$form.getAttribute("action"),{method:this.$form.getAttribute("method"),body:t,cache:"no-cache"}),s=e.headers.get("content-type")||"",o=await e.text();if(!e.ok)throw new Error("response not valid");if(0===s.indexOf("text/html")){var n=(0,_common_helper__WEBPACK_IMPORTED_MODULE_2__.Bv)(o);const e=n?n.querySelector(".js-modal-content"):null;if(_console__WEBPACK_IMPORTED_MODULE_1__.cM("$popupContent"),_console__WEBPACK_IMPORTED_MODULE_1__.cM(e),!e)throw new Error(`Could not find .js-modal-content in response from ${this.$form.getAttribute("action")}`);document.querySelector(".js-modal-content").replaceWith(e)}else window.StackExchange.helpers.showToast(this.cam.opt.adReportThanksText,{type:"success"}),this.removeModal()}catch(e){window.StackExchange.helpers.showToast(this.cam.opt.adReportErrorText,{type:"danger"})}finally{let e=this.$form.querySelector("[type=submit]");e&&e.removeAttribute("disabled")}}}},276:(e,t,s)=>{function n(...e){}function o(...e){}s.d(t,{cM:()=>n,vU:()=>o})}},__webpack_module_cache__={};function __webpack_require__(e){var t=__webpack_module_cache__[e];if(void 0!==t)return t.exports;var s=__webpack_module_cache__[e]={exports:{}};return __webpack_modules__[e](s,s.exports,__webpack_require__),s.exports}__webpack_require__.d=(e,t)=>{for(var s in t)__webpack_require__.o(t,s)&&!__webpack_require__.o(e,s)&&Object.defineProperty(e,s,{enumerable:!0,get:t[s]})},__webpack_require__.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var __webpack_exports__={};(()=>{var e=__webpack_require__(276),t=(e=>(e[e.Above=0]="Above",e[e.Below=1]="Below",e))(t||{});const s=Object.assign({},{"lib":"https://cdn.sstatic.net/clc/js/bundles/gam_loader_script/gam_loader_script.bundle.741.dd810f00b575c4c2c336.min.js","style":null,"u":null,"wa":true,"kt":2000,"tto":true,"h":"clc.stackoverflow.com","allowed":"^(((talent\\.)?stackoverflow)|(blog\\.codinghorror)|(.*\\.googlesyndication)|(serverfault|askubuntu)|([^\\.]+\\.stackexchange))\\.com$","wv":true,"al":false,"abd":true,"cpa_liid":[5882654614],"cpa_cid":[138377597667],"dp":false,"tgt_to":1000,"tgt_u":"https://clc.stackoverflow.com/get-user-acct-tgt","tgt_e":true,"tgt_p":10});var n=__webpack_require__(23),o=__webpack_require__(865),i=__webpack_require__(763);class r{constructor(t,s){this.googletag=t,this.interval=s,e.cM("Ad refresh init. interval: "+s),this.googletag.pubads().addEventListener("impressionViewable",e=>this.onImpressionViewable(e)),e.cM("done enabling ad refresh")}onImpressionViewable(t){var s=t.slot;e.cM("ad refresh - slot "+s.getSlotElementId()+" is viewable, initializing refresh"),this.scheduleRefresh(s)}scheduleRefresh(e){setTimeout(()=>this.refreshAdSlot(e),1e3*this.interval)}static refreshMyAd(t,s){let n=t.pubads().getSlots().find(e=>e.getSlotElementId()===s);n&&(e.cM("refreshMyAd - refreshing ad slot "+s),t.pubads().refresh([n]))}refreshAdSlot(t){var s=t.getSlotElementId();this.isElementVisibleInBrowser(s)?(e.cM("refreshing ad slot "+s),googletag.pubads().refresh([t])):(e.cM("refresh skipped this time; ad slot not viewable:"+s),this.scheduleRefresh(t))}isElementVisibleInBrowser(e){var t=document.getElementById(e);if(null!==t){var s=t.getBoundingClientRect();if(s.top>=0&&s.left>=0&&s.bottom<=(window.innerHeight||document.documentElement.clientHeight)&&s.right<=(window.innerWidth||document.documentElement.clientWidth))return!0}return!1}}var a=(e=>(e.Off="Off",e.PreSurvey="PreSurvey",e.Collect="Collect",e.PostSurvey="PostSurvey",e))(a||{});class d{constructor(e,t){this.lineItemImpressions=[],this.surveysIdsCompleted=[],this.lineItemImpressions=e,this.surveysIdsCompleted=t}addImpression(e,t){let s={brandId:e,lineItemId:t,timestamp:new Date};this.lineItemImpressions.push(s)}addBrandSurveyCompleted(e){-1===this.surveysIdsCompleted.indexOf(e)&&this.surveysIdsCompleted.push(e)}getTotalBrandImpressions(){let e=new Map;for(let t of this.lineItemImpressions)if(e.has(t.brandId)){let s=e.get(t.brandId);e.set(t.brandId,s+1)}else e.set(t.brandId,1);return e}getBrandLineItemImpressions(e){let t={};for(let s of this.lineItemImpressions)if(s.brandId==e)if(void 0!==t[s.lineItemId]){let e=t[s.lineItemId];t[s.lineItemId]=e+1}else t[s.lineItemId]=1;return t}}class l{constructor(){this.surveyEngagementLocalStorageKey="clc-survey-engagement"}getBrandSurveyEngagement(){let e=localStorage.getItem(this.surveyEngagementLocalStorageKey);if(null===e)return new d([],[]);let t=JSON.parse(e);return new d(t.lineItemImpressions,t.surveysIdsCompleted)}saveBrandSurveyEngagement(e){let t=JSON.stringify(e);localStorage.setItem(this.surveyEngagementLocalStorageKey,t)}}class c{constructor(){this.surveyRepository=new l}getBrandSurveyEngagement(){return this.surveyRepository.getBrandSurveyEngagement()}recordImpression(e,t){let s=this.getBrandSurveyEngagement();s.addImpression(e,t),this.surveyRepository.saveBrandSurveyEngagement(s)}recordBrandSurveyCompleted(e){let t=this.getBrandSurveyEngagement();t.addBrandSurveyCompleted(e),this.surveyRepository.saveBrandSurveyEngagement(t)}}class g{constructor(t,s){this.googletag=t,this.brandSettings=s,this.brandSlotMap=new Map,this.brandSurveyEngagementService=new c,e.cM("Brand Survey init: "+JSON.stringify(s)),void 0!==s?(this.googletag.pubads().addEventListener("slotRenderEnded",e=>this.handleSlotRendered(e)),this.googletag.pubads().addEventListener("impressionViewable",e=>this.onImpressionViewable(e)),e.cM("done enabling Brand Survey")):e.cM("Brand Survey init: brandSettings is undefined, not initializing")}handleSlotRendered(t){e.cM("Brand Survey - slot rendered - slot:"+JSON.stringify(t.slot.getSlotElementId())+" lineItem: "+t.lineItemId);let s=this.findItemWithId(t.lineItemId);if(null===s||s.mode!==a.Collect)this.brandSlotMap.delete(t.slot.getSlotElementId());else{let e={brandId:s.brandId,lineItemId:t.lineItemId};this.brandSlotMap.set(t.slot.getSlotElementId(),e)}}onImpressionViewable(t){let s=t.slot;if(e.cM("ad - Brand Survey - impression viewable. Details: "+JSON.stringify(s.getSlotElementId())),e.cM("ad - Brand Survey - slot "+s.getSlotElementId()+" is viewable"),this.brandSlotMap.has(s.getSlotElementId())){let t=this.brandSlotMap.get(s.getSlotElementId());e.cM("Brand Survey - brand "+t.brandId+" is viewable"),this.recordImpression(this.brandSlotMap.get(s.getSlotElementId()))}}recordImpression(t){e.cM("ad - Brand Survey - recording impression for brand "+t.brandId),this.brandSurveyEngagementService.recordImpression(t.brandId,t.lineItemId)}findItemWithId(t){return e.cM("brand settings: "+JSON.stringify(this.brandSettings)),this.brandSettings.find(e=>e.lineItemIds.includes(t))||null}}const p="response-brand-survey-submit|",h="request-brand-survey-metadata|",m="record-metric-on-server|",u="request-dsp-tags",f="response-dsp-tags|";class v{static refreshAdIfBrandSurveyIsDuplicated(e,t,s){this.alreadyCompletedThisBrandSurvey(t)&&r.refreshMyAd(e,s)}static alreadyCompletedThisBrandSurvey(e){return(new c).getBrandSurveyEngagement().surveysIdsCompleted.includes(e)}}window.cam=new class{constructor(t=null){if(this.gptImported=!1,this.slotsRenderedEvents=[],this.collapsed={},e.cM("constructor"),this.clc_options=s,window.clcGamLoaderOptions)Object.assign(this,window.clcGamLoaderOptions);else if(void 0===this.opt){let e=window.opt;e&&(this.opt=e)}}init(){if(e.cM("init"),void 0===this.opt)throw new Error("opt not set, required by GAM Loader");e.cM("init brand survey service"),this.getUserAccountTargetingPromise=this.getUserAccountTargeting(),e.cM("setup message handler"),window.addEventListener("message",e=>{this.onmessage(e)})}handleSlotRenderedNoAdReport(){if(googletag.pubads().addEventListener("slotRenderEnded",e=>this.applyExtraMarginBottom(e)),Array.isArray(this.slotsRenderedEvents))for(var e=0;e<this.slotsRenderedEvents.length;e++)this.applyExtraMarginBottom(this.slotsRenderedEvents[e])}onmessage(t){let s="omni";if(t.data&&("string"==typeof t.data||t.data instanceof String))if(0===t.data.indexOf("get-omni-")){e.cM("Recevied get-omni message, sending back omni");var n=t.source,i=this.opt.omni,r="string"==typeof i?i:"";n.postMessage([s,r,this.opt.perRequestGuid].join("|"),"*")}else if(0===t.data.indexOf("collapse-")){e.cM("Recevied collapse message, collapse ad iframe"),e.cM(t);for(var a=t.source.window,d=document.getElementsByTagName("IFRAME"),l=0;l<d.length;l++){var g=d[l];if(g.contentWindow==a)return void(0,o.wo)(g.parentElement.parentElement.parentElement)}}else if(0===t.data.indexOf("resize|")){e.cM("Recevied resize message, resize ad iframe"),e.cM(t);let s=this._getFrameByEvent(t),n=t.data.indexOf("|")+1,o=t.data.slice(n),i=parseFloat(o)+.5;e.cM("New iframe height "+i),s.height=i.toString(),s.parentElement.style.height=i.toString()+"px"}else if(0===t.data.indexOf("getmarkup|")){let s=t.data.indexOf("|")+1,n=t.data.slice(s);e.cM("Recevied get markup message: "+n);let o=this._getFrameByEvent(t).closest(".everyonelovesstackoverflow");const i=document.createElement("script");i.dataset.adZoneId=o.id,i.src=n,document.body.appendChild(i)}else if(0===t.data.indexOf("window-location|")){let s=t.data.indexOf("|")+1,n=t.data.slice(s);e.cM("Recevied window location message: "+n),n.startsWith("/")||(n="/"+n),window.open(window.location.protocol+"//"+window.location.host+n,"_blank")}else if(0===t.data.indexOf("request-brand-survey-submit|")){let s=t.data.split("|"),n=s[1],o=s[2],i=s[3],r=JSON.parse(i);e.cM(n),e.cM(o),e.cM(i),e.cM("Received brand survey "+n+" response message: "+o);var b=new FormData;for(var _ in r)b.append(_,r[_]);let a=this._getFrameByEvent(t);if(v.alreadyCompletedThisBrandSurvey(+n))return e.cM("Already completed this brand survey. Not submitting duplicate to server."),void a.contentWindow.postMessage("response-brand-survey-submit-duplicate|","*");e.cM("Send the brand survey to the server"),fetch(o,{method:"POST",body:b}).then(e=>e.json()).then(e=>a.contentWindow.postMessage(p,"*")).catch(e=>a.contentWindow.postMessage(p,"*"))}else if(0===t.data.indexOf("brand-survey-completed-store|")){let s=t.data.split("|"),n=(s[1],s[2]);if(e.cM("Received brand survey completed store message for survey ID "+n),v.alreadyCompletedThisBrandSurvey(+n))return void e.cM("Already completed this brand survey. Not recording duplicate locally.");e.cM("Record brand survey completion locally"),(new c).recordBrandSurveyCompleted(+n)}else if(0===t.data.indexOf(h)){let s=t.data.split("|"),n=s[1],o=s[2];e.cM("Received message: request-brand-survey-metadata| with Brand Survey ID "+o);let i=(new c).getBrandSurveyEngagement().getBrandLineItemImpressions(+n),r=JSON.stringify(i),a=this._getFrameByEvent(t);e.cM("sending impression data: "+r),a.contentWindow.postMessage("response-brand-survey-metadata|"+this.opt.responseHash+"|"+this.opt.perRequestGuid+"|"+r,"*")}else if(0===t.data.indexOf("refresh-if-duplicate-brand-survey|")){let e=t.data.split("|")[1],s=this.getSlotElementIdByEvent(t);v.refreshAdIfBrandSurveyIsDuplicated(googletag,+e,s)}else if(0===t.data.indexOf(m)){e.cM("Received message: record-metric-on-server| with args: "+t.data);let s=t.data.split("|"),n=s[1],o=s[2],i=s[3],r=s[4],a=new FormData;a.append("brandSurveyId",i.toString()),a.append("responseHash",this.opt.responseHash),a.append("perRequestGuid",this.opt.perRequestGuid),a.append("questionNumber",n.toString()),a.append("metricType",r.toString()),fetch(o,{method:"POST",body:a}).then(e=>e.ok).catch(t=>{e.cM("SendMetricToServer: Error sending metric to server: "+t)})}else if(0===t.data.indexOf(u)){e.cM("Received message: request-dsp-tags with args: "+t.data);let s=this._getFrameByEvent(t);if(!this.opt.targeting["so-tag"])return void s.contentWindow.postMessage(f,"*");const n=this.opt.targeting["so-tag"].join(",");e.cM("sending targeting tags: "+n),s.contentWindow.postMessage(f+n,"*")}else e.cM("Received unhandled message")}getSlotElementIdByEvent(e){let t=this._getFrameByEvent(e).parentElement?.parentElement?.id;return t||""}_getFrameByEvent(e){return Array.from(document.getElementsByTagName("iframe")).filter(t=>t.contentWindow===e.source)[0]}classifyZoneIds(e){const t=e.map(o.Nj).filter(o.yb);return{eligible:t.filter(o.xb).filter(o.pn),ineligible:t.filter(o.xj)}}applyExtraMarginBottom(t){if(t&&t.slot&&!t.isEmpty&&(t.creativeId||t.lineItemId||!t.isEmpty)){var s=t.slot.getSlotElementId();if(s){var o=document.getElementById(s);if(o)if((0,n.eq)(s)){var i=o?.closest(".js-zone-container");i.style.marginBottom="24px",e.cM("Applied extra margin to the bottom of "+s)}else e.cM("Not applying extra margin to the bottom of "+s+": shouldHaveReportButton = false");else e.cM("Not applying extra margin to the bottom of "+s+": resolved invalid adUnit element")}else e.cM("Not applying extra margin to the bottom of element: invalid adUnitElementId")}else e.cM("Not applying extra margin to the bottom of element: invalid SlotRenderEndedEvent")}async load(s=(0,n.kG)()){const a=this.opt.tlb_position===t.Above?["dfp-mlb","dfp-smlb"]:["dfp-mlb","dfp-smlb","dfp-tlb"];if(!this.isGptReady())return e.cM("Initializing..."),this.initGpt(),void googletag.cmd.push(()=>this.load(s));this.opt.adReportEnabled?(e.cM("Ad reporting enabled"),this.adReports=new i.t(googletag,this)):(e.cM("Ad reporting not enabled"),this.handleSlotRenderedNoAdReport()),this.opt.refresh?(e.cM("Ad refresh enabled"),this.adRefresh=new r(googletag,this.opt.refreshInterval)):e.cM("Ad refresh not enabled"),this.opt.brandSurveyEnabled&&(e.cM("Brand Survey enabled"),this.brandSurvey=new g(googletag,this.opt.brandSurveySettings)),e.cM("Attempting to load ads into ids: ",s);const{eligible:d,ineligible:l}=this.classifyZoneIds(s);if(this.initDebugPanel(googletag,d.concat(l)),d.forEach(e=>(0,o.cf)(e)),l.forEach(o.wo),0===d.length)return void e.cM("Found no ad ids on page");e.cM("Eligible ids:",d),this.opt.abd&&this.appendAdblockDetector();var c=googletag.pubads().getSlots();if(c){var p=c.filter(e=>s.indexOf(e.getSlotElementId())>=0);googletag.destroySlots(p)}this.opt.sf&&(googletag.pubads().setForceSafeFrame(!0),googletag.pubads().setSafeFrameConfig({allowOverlayExpansion:!0,allowPushExpansion:!0,sandbox:!0})),e.cM("Targeting consent: Checking...");let h=!1,m=!1;void 0!==this.opt.targeting_consent&&(m=!0,e.cM("Targeting consent: Parameter set"),e.cM("Targeting consent: Consent given? ",this.opt.targeting_consent),h=this.opt.targeting_consent),void 0!==this.opt.personalization_consent&&(e.cM("Personalization consent: Parameter set"),e.cM("Personalization consent: Consent given? ",this.opt.personalization_consent),h=h&&this.opt.personalization_consent),h=h&&m,this.setPrivacySettings(h),this.opt.ll||googletag.pubads().enableSingleRequest(),cam.sreEvent||(googletag.pubads().addEventListener("slotRenderEnded",e=>this.onSlotRendered(e)),cam.sreEvent=!0),await this.setTargeting();var u=d.filter(e=>!this.opt.ll||a.indexOf(e.id)<0),f=d.filter(e=>!!this.opt.ll&&a.indexOf(e.id)>=0);e.cM("Up front ids:",u),e.cM("Lazy loaded ids:",f),u.forEach(t=>{e.cM(`Defining ad for element ${t.id}`),this.defineSlot(t.id,googletag),t.setAttribute("data-dfp-zone","true")}),googletag.enableServices(),u.forEach(t=>{e.cM(`Displaying ad for element ${t.id}`),googletag.cmd.push(()=>googletag.display(t.id))}),this.opt.ll&&(e.cM("Enabling lazy loading for GAM"),googletag.pubads().enableLazyLoad({fetchMarginPercent:0,renderMarginPercent:0}),e.cM("Setting up lazy loaded ad units"),f.forEach(t=>{e.cM(`Lazy loading - Defining Slot ${t.id}`),this.defineSlot(t.id,googletag)}),f.forEach(t=>{e.cM(`Lazy loading - Displaying ad for element ${t.id}`),googletag.cmd.push(()=>googletag.display(t.id))}))}setPrivacySettings(e){e?googletag.pubads().setPrivacySettings({limitedAds:!1,nonPersonalizedAds:!1}):googletag.pubads().setPrivacySettings({limitedAds:!0,nonPersonalizedAds:!0})}async setTargeting(){if(!googletag)throw new Error("googletag not defined");let t=this.opt.targeting;if(!t)throw new Error("Targeting not defined (is "+typeof t+")");Object.keys(t).forEach(s=>{e.cM(`-> targeting - ${s}: ${t[s]}`),googletag.pubads().setTargeting(s,t[s])});let s=!1;if(void 0!==this.opt.targeting_consent&&(s=this.opt.targeting_consent),s){let t=(new c).getBrandSurveyEngagement();if(t.getTotalBrandImpressions().forEach((t,s)=>{e.cM(`-> targeting - BrandImpressions: ${s}: ${t}`),googletag.pubads().setTargeting("brand_"+s.toString()+"_impressions",t.toString())}),t.surveysIdsCompleted.forEach(t=>{e.cM(`-> targeting - SurveysTaken: ${t}`),googletag.pubads().setTargeting("survey_"+t+"_taken","true")}),this.clc_options.tgt_e&&this.getUserAccountTargetingPromise){let t=await this.getUserAccountTargetingPromise;t&&t.tgt_acct?(e.cM("-> targeting - User Account: "+t.tgt_acct),googletag.pubads().setTargeting("user-acct",t.tgt_acct)):e.cM("-> targeting - User Account: Not Found")}}}appendAdblockDetector(){const e=document.createElement("div");e.className="adsbox",e.id="clc-abd",e.style.position="absolute",e.style.pointerEvents="none",e.innerHTML="&nbsp;",document.body.appendChild(e)}onSlotRendered(s){try{const r=s.slot.getSlotElementId();let a=[];r||a.push("id=0");const d=document.getElementById(r);if(r&&!d&&a.push("el=0"),0!==a.length)return void this.stalled(a.join("&"));const{path:l,sizes:c,zone:g}=(0,n.Z7)(r);if(this.collapsed[g]&&s.isEmpty)return e.cM(`No line item for the element #${d.id}... collapsing.`),void(0,o.wo)(d);if(this.slotsRenderedEvents.push(s),s.lineItemId||s.creativeId||!s.isEmpty){e.cM(`Rendered ad for element #${d.id} [line item #${s.lineItemId}]`),e.cM(s);var i=d.parentElement;if(i.classList.contains("js-zone-container")){switch((0,o.cf)(i),r){case"dfp-tlb":this.opt.tlb_position===t.Above?i.classList.add("mb8"):i.classList.add("mt16");break;case"dfp-tag":i.classList.add("mb8");break;case"dfp-msb":i.classList.add("mt16");break;case"dfp-mlb":case"dfp-smlb":case"dfp-bmlb":i.classList.add("my8");break;case"dfp-isb":i.classList.add("mt24");break;case"dfp-m-aq":i.classList.add("my12"),i.classList.add("mx-auto")}(0,o.$Z)(i),(0,o.$Z)(d)}else e.cM(`No ad for element #${d.id}, collapsing`),e.cM(s),(0,o.wo)(d)}}catch(t){e.cM("Exception thrown onSlotRendered"),e.cM(t),this.stalled("e=1")}}stalled(e){(new Image).src=`https://${this.clc_options.h}/stalled.gif?${e}`}defineSlot(t,s){"dfp-isb"===t&&(e.cM("-> targeting - Sidebar: Inline"),s.pubads().setTargeting("Sidebar",["Inline"])),"dfp-tsb"===t&&(e.cM("-> targeting - Sidebar: Right"),s.pubads().setTargeting("Sidebar",["Right"]));const{path:o,sizes:i,zone:r}=(0,n.Z7)(t);e.cM(`Defining slot for ${t}: ${o}, sizes: ${JSON.stringify(i)}`),s.defineSlot(o,i,t).addService(s.pubads())}importGptLibrary(){this.gptImported||(this.gptImported=!0,void 0===this.opt.targeting_consent||this.opt.targeting_consent?(0,o.Gx)("https://securepubads.g.doubleclick.net/tag/js/gpt.js"):(0,o.Gx)("https://pagead2.googlesyndication.com/tag/js/gpt.js"))}isGptReady(){return"undefined"!=typeof googletag&&!!googletag.apiReady}initGpt(){"undefined"==typeof googletag&&(window.googletag={cmd:(0,o.QZ)(()=>this.importGptLibrary())})}getUserAccountTargeting(){if(this.opt.allowAccountTargetingForThisRequest&&this.clc_options.tgt_e&&this.clc_options.tgt_p>0){if(e.cM("Targeting enabled."),this.clc_options.tgt_p<100){e.cM("Targeting rate limit enabled. Rolling the dice...");const t=Math.floor(100*Math.random())+1;if(e.cM("Rolled "+t+" and the max is "+this.clc_options.tgt_p),t>this.clc_options.tgt_p)return void e.cM("Will not request targeting.")}return e.cM("Will request targeting."),function(e,t,s){if(e){const e=new Headers;return e.append("Accept","application/json"),async function(e,t={},s=5e3){if("number"!=typeof s&&null!=s&&!1!==s){if("string"!=typeof s)throw new Error("fetchWithTimeout: timeout must be a number");if(s=parseInt(s),isNaN(s))throw new Error("fetchWithTimeout: timeout must be a number (or string that can be parsed to a number)")}const n=new AbortController,{signal:o}=n,i=fetch(e,{...t,signal:o}),r=setTimeout(()=>n.abort(),s);try{const e=await i;return clearTimeout(r),e}catch(e){throw clearTimeout(r),e}}(t,{method:"GET",mode:"cors",headers:e},s).then(e=>e.json())}return Promise.reject("No consent")}(this.opt.targeting_consent,this.clc_options.tgt_u,this.clc_options.tgt_to).catch(t=>{e.vU("Error fetching user account targeting"),e.vU(t)})}e.cM("Targeting disabled. Will not request account targeting data.")}initDebugPanel(t,s){e.cM("initDebugPanel"),e.cM("Not showing debug panel")}},window.clcGamLoaderOptions&&(cam.init(),cam.load())})()})();</script>
+
+ <footer id="footer" class="site-footer js-footer theme-light__forced" role="contentinfo">
+ <div class="site-footer--container">
+ <div class="site-footer--logo">
+
+ <a href="https://stackoverflow.com" aria-label="Stack Overflow"><svg aria-hidden="true" class="native svg-icon iconLogoGlyphMd" width="32" height="37" viewBox="0 0 32 37"><path d="M26 33v-9h4v13H0V24h4v9h22Z" fill="#BCBBBB"/><path d="m21.5 0-2.7 2 9.9 13.3 2.7-2L21.5 0ZM26 18.4 13.3 7.8l2.1-2.5 12.7 10.6-2.1 2.5ZM9.1 15.2l15 7 1.4-3-15-7-1.4 3Zm14 10.79.68-2.95-16.1-3.35L7 23l16.1 2.99ZM23 30H7v-3h16v3Z" fill="#F48024"/></svg></a>
+ </div>
+ <nav class="site-footer--nav">
+ <div class="site-footer--col">
+ <h5 class="-title"><a href="https://stackoverflow.com" class="js-gps-track" data-gps-track="footer.click({ location: 2, link: 15})">Stack Overflow</a></h5>
+ <ul class="-list js-primary-footer-links">
+ <li><a href="/questions" class="js-gps-track -link" data-gps-track="footer.click({ location: 2, link: 16})">Questions</a></li>
+ <li><a href="/help" class="js-gps-track -link" data-gps-track="footer.click({ location: 2, link: 3 })">Help</a></li>
+ </ul>
+ </div>
+ <div class="site-footer--col">
+ <h5 class="-title"><a href="https://stackoverflow.co/" class="js-gps-track" data-gps-track="footer.click({ location: 2, link: 19 })">Products</a></h5>
+ <ul class="-list">
+ <li><a href="https://stackoverflow.co/teams/" class="js-gps-track -link"
+ data-ga="[&quot;teams traffic&quot;,&quot;footer - site nav&quot;,&quot;stackoverflow.com/teams&quot;,null,{&quot;dimension4&quot;:&quot;teams&quot;}]"
+ data-gps-track="footer.click({ location: 2, link: 29 })">Teams</a></li>
+ <li><a href="https://stackoverflow.co/advertising/" class="js-gps-track -link" data-gps-track="footer.click({ location: 2, link: 21 })">Advertising</a></li>
+ <li><a href="https://stackoverflow.co/collectives/" class="js-gps-track -link" data-gps-track="footer.click({ location: 2, link: 40 })">Collectives</a></li>
+ <li><a href="https://stackoverflow.co/talent/" class="js-gps-track -link" data-gps-track="footer.click({ location: 2, link: 20 })">Talent</a></li>
+ </ul>
+ </div>
+ <div class="site-footer--col">
+ <h5 class="-title"><a class="js-gps-track" data-gps-track="footer.click({ location: 2, link: 1 })" href="https://stackoverflow.co/">Company</a></h5>
+ <ul class="-list">
+ <li><a class="js-gps-track -link" data-gps-track="footer.click({ location: 2, link: 1 })" href="https://stackoverflow.co/">About</a></li>
+ <li><a class="js-gps-track -link" data-gps-track="footer.click({ location: 2, link: 27 })" href="https://stackoverflow.co/company/press/">Press</a></li>
+ <li><a class="js-gps-track -link" data-gps-track="footer.click({ location: 2, link: 9 })" href="https://stackoverflow.co/company/work-here/">Work Here</a></li>
+ <li><a class="js-gps-track -link" data-gps-track="footer.click({ location: 2, link: 7 })" href="https://stackoverflow.com/legal">Legal</a></li>
+ <li><a class="js-gps-track -link" data-gps-track="footer.click({ location: 2, link: 8 })" href="https://stackoverflow.com/legal/privacy-policy">Privacy Policy</a></li>
+ <li><a class="js-gps-track -link" data-gps-track="footer.click({ location: 2, link: 37 })" href="https://stackoverflow.com/legal/terms-of-service/public">Terms of Service</a></li>
+ <li><a class="js-gps-track -link" data-gps-track="footer.click({ location: 2, link: 13 })" href="https://stackoverflow.co/company/contact/">Contact Us</a></li>
+ <li class="" id="consent-footer-link"><a class="js-gps-track -link js-cookie-settings" data-gps-track="footer.click({ location: 2, link: 38 })" href="#" data-consent-popup-loader="footer">Cookie Settings</a></li>
+ <li><a class="js-gps-track -link" data-gps-track="footer.click({ location: 2, link: 39 })" href="https://stackoverflow.com/legal/cookie-policy">Cookie Policy</a></li>
+ </ul>
+ </div>
+ <div class="site-footer--col site-footer--categories-nav">
+ <div>
+ <h5 class="-title"><a href="https://stackexchange.com" data-gps-track="footer.click({ location: 2, link: 30 })">Stack Exchange Network</a></h5>
+ <ul class="-list">
+ <li>
+ <a href="https://stackexchange.com/sites#technology" class="-link js-gps-track" data-gps-track="footer.click({ location: 2, link: 24 })">
+ Technology
+ </a>
+ </li>
+ <li>
+ <a href="https://stackexchange.com/sites#culturerecreation" class="-link js-gps-track" data-gps-track="footer.click({ location: 2, link: 24 })">
+ Culture &amp; recreation
+ </a>
+ </li>
+ <li>
+ <a href="https://stackexchange.com/sites#lifearts" class="-link js-gps-track" data-gps-track="footer.click({ location: 2, link: 24 })">
+ Life &amp; arts
+ </a>
+ </li>
+ <li>
+ <a href="https://stackexchange.com/sites#science" class="-link js-gps-track" data-gps-track="footer.click({ location: 2, link: 24 })">
+ Science
+ </a>
+ </li>
+ <li>
+ <a href="https://stackexchange.com/sites#professional" class="-link js-gps-track" data-gps-track="footer.click({ location: 2, link: 24 })">
+ Professional
+ </a>
+ </li>
+ <li>
+ <a href="https://stackexchange.com/sites#business" class="-link js-gps-track" data-gps-track="footer.click({ location: 2, link: 24 })">
+ Business
+ </a>
+ </li>
+
+ <li class="mt16 md:mt0">
+ <a href="https://api.stackexchange.com/" class="-link js-gps-track" data-gps-track="footer.click({ location: 2, link: 24 })">
+ API
+ </a>
+ </li>
+
+ <li>
+ <a href="https://data.stackexchange.com/" class="-link js-gps-track" data-gps-track="footer.click({ location: 2, link: 24 })">
+ Data
+ </a>
+ </li>
+ </ul>
+ </div>
+ </div>
+ </nav>
+ <div class="site-footer--copyright fs-fine md:mt24">
+ <ul class="-list -social md:mb8">
+ <li><a class="js-gps-track -link" data-gps-track="footer.click({ location: 2, link:4 })" href="https://stackoverflow.blog?blb=1">Blog</a></li>
+ <li><a href="https://www.facebook.com/officialstackoverflow/" class="-link js-gps-track" data-gps-track="footer.click({ location: 2, link: 31 })">Facebook</a></li>
+ <li><a href="https://twitter.com/stackoverflow" class="-link js-gps-track" data-gps-track="footer.click({ location: 2, link: 32 })">Twitter</a></li>
+ <li><a href="https://linkedin.com/company/stack-overflow" class="-link js-gps-track" data-gps-track="footer.click({ location: 2, link: 33 })">LinkedIn</a></li>
+ <li><a href="https://www.instagram.com/thestackoverflow" class="-link js-gps-track" data-gps-track="footer.click({ location: 2, link: 36 })">Instagram</a></li>
+ </ul>
+
+ <p class="md:mb0">
+Site design / logo &#169; 2023 Stack Exchange Inc; user contributions licensed under <span class='td-underline'><a href="https://stackoverflow.com/help/licensing">CC BY-SA</a></span>. <span id="svnrev">rev&nbsp;2023.12.13.2607</span>
+ </p>
+ </div>
+ </div>
+
+ </footer>
+
+
+
+
+ <!-- Google tag (gtag.js) -->
+ <script async src="https://www.googletagmanager.com/gtag/js?id=G-WCZ03SZFCQ"></script>
+ <script>
+ window.dataLayer = window.dataLayer || [];
+ function gtag() { dataLayer.push(arguments); }
+ </script>
+ <script>
+ StackExchange.ready(function() {
+
+ var ga3Settings = {
+ autoLink: ["stackoverflow.blog","info.stackoverflowsolutions.com","stackoverflowsolutions.com"],
+ sendTitles: true,
+ tracker: window.ga,
+ trackingCodes: [
+ 'UA-108242619-1'
+ ],
+ checkDimension: 'dimension42'
+ };
+
+ var customGA4Dimensions = {};
+
+
+ customGA4Dimensions["routename"] = "Questions/Show";
+
+
+ customGA4Dimensions["post_id"] = "7015668";
+
+ customGA4Dimensions["tags"] = "|javascript|closures|";
+
+
+ var ga4Settings = {
+ tracker: gtag,
+ trackingCodes: [
+ 'G-WCZ03SZFCQ'
+ ],
+ consentsToPerformanceCookies: "denied",
+ consentsToTargetingCookies: "denied",
+ eventParameters: customGA4Dimensions,
+ checkForAdBlock: true,
+ sendTitles: true,
+ trackClicks: false,
+ };
+
+ StackExchange.ga.init({ GA3: ga3Settings, GA4: ga4Settings });
+
+
+ StackExchange.ga.setDimension('dimension2', '|javascript|closures|');
+
+
+ StackExchange.ga.setDimension('dimension3', 'Questions/Show');
+
+
+ StackExchange.ga.setDimension('dimension7', "1702565845.780746742");
+
+ StackExchange.ga.trackPageView();
+ });
+ </script>
+
+
+ <div id="onetrust-consent-sdk" class="d-none"></div>
+ <div id="onetrust-banner-sdk" data-controller="s-modal"></div>
+ <div id="ot-pc-content" class="d-none"></div>
+ <div id="onetrust-style" class="d-none">&nbsp;</div>
+ <div class="d-none js-consent-banner-version" data-consent-banner-version="1"></div>
+
+
+
+
+ </body>
+ </html>
+
diff --git a/frontend/src/lib/components/Code.svelte b/frontend/src/lib/components/Code.svelte
index 3de30072..d0c3ef14 100644
--- a/frontend/src/lib/components/Code.svelte
+++ b/frontend/src/lib/components/Code.svelte
@@ -4,25 +4,25 @@
export let code: string;
export let transparentBackground = false;
- $: codeHasNewlines = code.includes('\n');
+ $: isInline = !code.includes('\n');
</script>
-{#if codeHasNewlines}
+{#if isInline}
+ <span
+ class="code rounded-md {transparentBackground ? '' : 'bg-base-200'} text-neutral-focus inline-block mx-1"
+ >
+ <span class="overflow-auto px-2">
+ <code>{code}</code>
+ </span>
+ </span>
+{:else}
<div
- class="code rounded-lg {transparentBackground ? '' : 'bg-base-200'} text-sm text-neutral-focus"
+ class="code rounded-lg {transparentBackground ? '' : 'bg-base-200'} text-neutral-focus my-2"
>
<div class="overflow-auto px-3 py-2">
<HighlightAuto {code} />
</div>
</div>
-{:else}
- <span
- class="code rounded-lg {transparentBackground ? '' : 'bg-base-200'} text-sm text-neutral-focus"
- >
- <span class="overflow-auto px-3 py-2">
- <code>{code}</code>
- </span>
- </span>
{/if}
<style lang="postcss">
diff --git a/frontend/src/routes/search/+page.svelte b/frontend/src/routes/search/+page.svelte
index 9c6058c9..8c279aab 100644
--- a/frontend/src/routes/search/+page.svelte
+++ b/frontend/src/routes/search/+page.svelte
@@ -151,7 +151,7 @@
<Searchbar {query} />
</div>
<div class="mx-auto flex w-full justify-between">
- <div class="flex h-full flex-col justify-center space-x-2 text-xs text-neutral">
+ <div class="flex h-full flex-col justify-center space-x-2 text-sm text-neutral">
<p class="h-fit">
{#if results.numHits != null}
Found <span class="font-medium">{results.numHits.toLocaleString()}</span> results in <span class="font-medium">{(
diff --git a/frontend/src/routes/search/StackOverflow.svelte b/frontend/src/routes/search/StackOverflow.svelte
index 3f825924..be6d7b06 100644
--- a/frontend/src/routes/search/StackOverflow.svelte
+++ b/frontend/src/routes/search/StackOverflow.svelte
@@ -2,6 +2,7 @@
import HandThumbUp from '~icons/heroicons/hand-thumb-up';
import type { StackOverflowAnswer } from '$lib/api';
import Code from '$lib/components/Code.svelte';
+ import StackOverflowText from './StackOverflowText.svelte';
export let title: string;
export let answer: StackOverflowAnswer;
@@ -28,12 +29,12 @@
</div>
</div>
<hr class="border-stone-700" />
- <div class="space-y-3 text-sm inline-block max-h-96 overflow-y-scroll">
+ <div class="text-sm inline-block max-h-96 overflow-y-scroll">
{#each answer.body as part}
{#if part.type == 'code'}
<Code code={part.value} />
{:else if part.type == 'text'}
- <span>{part.value}</span>
+ <StackOverflowText text={part.value} />
{/if}
{/each}
</div>
diff --git a/frontend/src/routes/search/StackOverflowSnippet.svelte b/frontend/src/routes/search/StackOverflowSnippet.svelte
index e9a0fef0..26052c3f 100644
--- a/frontend/src/routes/search/StackOverflowSnippet.svelte
+++ b/frontend/src/routes/search/StackOverflowSnippet.svelte
@@ -3,6 +3,7 @@
import Code from '$lib/components/Code.svelte';
import HandThumbUp from '~icons/heroicons/hand-thumb-up';
import Check from '~icons/heroicons/check';
+ import StackOverflowText from './StackOverflowText.svelte';
export let question: StackOverflowQuestion;
export let answers: StackOverflowAnswer[];
@@ -15,7 +16,7 @@
{/if}
{/each}
</div>
-<div class="flex space-x-4 pt-2">
+<div class="flex space-x-4 pt-2 text-xs">
{#each answers.slice(0, 3) as answer}
<div class="w-1/3 overflow-hidden">
<a
@@ -43,7 +44,7 @@
<div>
{#each answer.body as passage}
{#if passage.type == 'text'}
- {passage.value}
+ <StackOverflowText text={passage.value} />
{:else if passage.type == 'code'}
<Code code={passage.value} transparentBackground={true} />
{/if}
diff --git a/frontend/src/routes/search/StackOverflowText.svelte b/frontend/src/routes/search/StackOverflowText.svelte
new file mode 100644
index 00000000..ec2d5218
--- /dev/null
+++ b/frontend/src/routes/search/StackOverflowText.svelte
@@ -0,0 +1,45 @@
+<script lang="ts">
+ export let text: string;
+
+ type TextOrBreak =
+ | {
+ type: 'text';
+ value: string;
+ }
+ | {
+ type: 'break';
+ value: string;
+ };
+
+
+ // split text into a stream of text and break elements
+ $: paragraphs = text
+ .split('\n')
+ .map((line) => line.trim())
+ .filter((line) => line.length > 0)
+ .flatMap((line) => {
+ return [
+ {
+ type: 'text',
+ value: line,
+ },
+ {
+ type: 'break',
+ value: '\n',
+ },
+ ];
+ }) as TextOrBreak[];
+
+ // remove the last break
+ $: paragraphs.pop();
+
+</script>
+
+{#each paragraphs as paragraph}
+ {#if paragraph.type == 'text'}
+ {paragraph.value}
+ {:else if paragraph.type == 'break'}
+ <br />
+ <br />
+ {/if}
+{/each}
diff --git a/frontend/src/routes/search/ThesaurusWidget.svelte b/frontend/src/routes/search/ThesaurusWidget.svelte
index 53713e41..63d2cdc1 100644
--- a/frontend/src/routes/search/ThesaurusWidget.svelte
+++ b/frontend/src/routes/search/ThesaurusWidget.svelte
@@ -6,7 +6,6 @@
import ThesaurusWidgetMeaning from './ThesaurusWidgetMeaning.svelte';
export let widget: ThesaurusWidget;
- console.log(widget);
// convert meanings into a list of either pos or meanings
enum MeaningType {