array.push replacing all the items here the src code   let mod_src_0 = "str1"; let mod_src_1 = "str2"; let mod_src_array = [mod_src_0,mod_src_1]; let mod_src_export = [];  let mod_obj = function(){      let temp = {};     for(let mod in mod_src_array){         temp.id = mod_src_array[mod];          mod_src_export.push(temp);     }        console.log(mod_src_export)   } mod_obj()   and the result is [ { id: 'str2' }, { id: 'str2' } ] instead of [ { id: 'str1' }, { id: 'str2' } ]  why is this happening? does it have anything to do with the javascript array.push function?
Is JavaScript a pass-by-reference or pass-by-value language? The primitive types (number, string, etc.) are passed by value, but objects are unknown, because they can be both passed-by-value (in case we consider that a variable holding an object is in fact a reference to the object) and passed-by-reference (when we consider that the variable to the object holds the object itself).  Although it doesn't really matter at the end, I want to know what is the correct way to present the arguments passing conventions. Is there an excerpt from JavaScript specification, which defines what should be the semantics regarding this?
Stack Exchange Android app keeps replaying notifications Version of the app: 1.0.51. (It is up to date at the time of writing according to Google Play.)  This started happening after the network problem that happened earlier this morning. Both my tablet and my phone are popping up notifications for events (comments, and probably edits too) that happened prior to the network issue. I had received notifications for these events already and had already cleared them before the network issue happened.  The repeated notifications do not show up in the bar displayed at the top of the Stack Exchange sites. In other words, I get notified again in Android but do not get notified again on the SE web sites. Linear Combination of Random Normal Variables In order to prove that the linear combination of two independent normal distributions(say Z=X+Y) is normal, i am using their MGFs to show that the linear combination also has a similar mgf. This works okay when Z = X+Y. But when Z=X-Y, i run into trouble :  E[$e^{tZ}$] = E[$e^{t(X-Y)}$] = E[$e^{tX}$]E[$e^{-tY}$]  Now i cannot put this as $M_{x}$(t) * $M_{y}$(t) because of the negative sign. So a company decides to raise money by selling shares of its stock. The stock is offered at an initial price of their determination. The stock is then traded in a market where forces of supply and demand, as well as speculation, affect its price.  When a company performs well (or makes decisions that will likely increase the company's earnings in the future), more people want to buy that stock than do people wanting to sell it. This creates demand for that stock which causes its sell/bid prices rise. When a company performs poorly, the opposite occurs; more people want to sell the stock than want to buy. This creates a surplus that causes sell/bid prices to fall.  Understanding this, people speculate over company performance to determine the future behavior of a stock, and attempt to "buy low, sell high" or "borrow high, return low" in order to make a profit.  But my question is regarding the first part of that process. What is it about company performance that causes the perceived value of its stock to rise? This is especially perplexing since I would guess that most people don't exercise their voting rights, and many stocks don't pay dividends.  It's not like a shareholder has any direct financial gains from increased company earnings (speculative stock pricing notwithstanding).  What is the intrinsic value of the stock?  It seems to me that all participants in a stock market tacitly agree that stock price will have a direct correlation with company performance. So another way of asking the question is, would an opposite agreement hold? What financially (this isn't a question about logistics, communication, or feasibility) stops all participants in a market from agreeing to value a particular company's stock inversely with respect to the company's performance?  Since I feel like I can't quite nail down my question, another form of it would be, why is stock market behavior driven by company performance? The representative point of a cluster or cluster center for the k-means algorithm is the component-wise mean of the points in its cluster. The mean is chosen because it helps to minimize the within cluster variances (which is to say that it is minimizing within cluster squared Euclidean distance, since its the same). Now, when I want to use a different distance metric, like L1 (Manhattan distance), I would be minimizing the within cluster absolute deviations (if I choose to). I was looking at what the centers calculation would be like, because the mean won't reduce the new objective function, and I found this on the Matlab documentation of their kmeans function for the distance parameter     cityblock - Sum of absolute differences, i.e., the L1 distance. Each centroid is the component-wise median of the points in that cluster.   Now, how did they come up with the component-wise median? How does a median minimize absolute deviations? LaTeX: optional arguments with square brackets LaTeX is trying to add a missing $ that I don't want to the following code. Minimal working example:  \documentclass[letter,12pt]{article}  \newcommand{\monkeyBeans}[2][]{   \parbox{4in}{#1} }  \begin{document}  \parbox{4in}{$[a, b]$}   \monkeyBeans[$[a, b]$]{yo monkey}  \end{document}   If I try any of the following lines in my document instead of the call to monkeyBeans, there is no error:  \parbox{4in}{$[a, b]$}  \monkeyBeans[yo monkey]{$[a, b]$} \monkeyBeans[$(a, b)$]{yo monkey} \monkeyBeans{$[a, b]$}{yo monkey}   What is the deal with square brackets in optional arguments? Solving Hardy Weinberg problems I really fail to understand Hardy-Weinberg equilibrium and can't find an easy enough source of information.  Can you help me to understand Hardy-Weinberg equilibrium?  My goal is to be able to solve the following kind of problem     In a population with two alleles for a certain locus, B and b, the allele frequency of B is 0.7. What is the frequency of heterozygotes if the population is in Hardy-Weinberg equilibrium? Dependency is not satisfiable: libtiff4 when trying to install Lightworks on Ubuntu 14.04 I was trying to install Lightworks 11.5.1 (amd64) on Ubuntu 14.04(amd64) but there's a notice: Dependency is not satisfiable: libtiff4. Is there anyway to solve this dependency issue?  Thanks in advance. Reshape three column data frame to matrix ("long" to "wide" format) What's the difference between :: (double colon) and -> (arrow) in PHP? comparing the first column of two files and printing the entire row of the second file if the first columns match I have two files in these formats:   file1 :  air smell hand dude road cat   file 2:   air,4,21,01,13,3,2 smell,21,4,2,5,6 dude,1,31,42,1 road,1,4,2,1,4 cat,1,5,6,3,1 hand,1,4,2,1,6 mouse,1,3,5,6,2   what I want to do is print the entire row of file 2, if the first string in column 1 of file 2 is found in file 1, and I want to keep the order of file 1.   expected output:   air,4,21,01,13,3,2 smell,21,4,2,5,6 hand,1,4,2,1,6 dude,1,31,42,1 road,1,4,2,1,4 cat,1,5,6,3,1 Add-on for blocking sites in Google Search How to get color of pixel in coordinates 123, 456 in screen? My AppleScript app needs to get color of pixel in coordinates 123, 456 in screen. What can i put into \setmathfont{&lt;...&gt;.otf} for the unicode-math package to make it all work (with XeLaTeX or LuaLaTeX)?  There are several suggestions on the  of unicode-math, but the first option is commercial, and the second and the third do not work with the following example:  % !TEX TS-program = xelatex  \documentclass{article} \usepackage{unicode-math} \setmathfont{latinmodern-math.otf} % \setmathfont{texgyrepagella-math.otf} % \setmathfont{xits-math.otf}  \begin{document} $X\setminus Y$ \end{document}   I do not get the \setminus character in the output.  The \setminus character is also missing if i do not set a math font at all (i do not know which font is used in this case).  It works with xits-math, but i do not like it.  Is it expected by the way that the \setminus character is left blank without giving any warning? Ubuntu stuck/freeze on install I've been trying to replace my current Windows 10 installation with Ubuntu 16.04. My computer is a Lenovo Thinkpad T470. I've formatted my 15GB USB-dongle. Downloaded the software Rufus, and burned the ISO onto the USB. I've tried the settings "MBR Partition for BIOS or UEFI", "MBR Partition for UEFI" and "GPT partition for UEFI". I've tried using memtest86+ to test if I have any memory errors, I have not. I've tried disabling Secure boot, and Fast startup. I've tried using other software than Rufus, and I've tried entering the "nomodeset" in the boot options, as well "acpi=off", nothing works.   When I boot from my USB. I choose "Install Ubuntu" from the grub menu. And then select my language in the installer. It is from this point on, it gets problematic. Sometimes when I try to connect to my WIFI, it connects successfully, but when I press the "continue" button, the installer freezes and nothing happens. Sometimes I get past this point, but it then freezes later on in the installation progress - typically right when I press the "Install now" button.   It should also be mentioned that, if I press the "Quit" button in the install. I get to a black screen with a lot of text saying something like squashfs error.   Can someone please help me? When I tried booting memtest86+ it only worked when I changed my boot mode from UEFI to Legacy. Could this be it? Are there any downsides to installing an operating system in legacy?   If anyone has any other suggestions, it would be greatly appreciated!  Thank you :-) In Fantastic Beasts: The Crimes of Grindelwald Dumbledore teaches DADA. But from the books we always heard about him as of a Transfiguration teacher (say, in Tom Riddle's days). It is stated in the movie that Dumbledore was prohibited to teach DADA by the Ministry, though the limitations seemed to be canceled at the end of the movie together with the removal of his handcuffs (not completely clear about the teaching though). The strange thing is, however, that Dumbledore was a Transfiguration teacher and even the Head of Transfiguration Department in Hogwarts before Newt's days, as we learn from Pottermore:  Under the guidance of her [McGonagall] inspirational Transfiguration teacher, Albus Dumbledore, she had managed to become an Animagus She [McGonagall] sent an owl to Hogwarts, asking whether she might be considered for a teaching post. The owl returned within hours, offering her a job in the Transfiguration department, under Head of Department, Albus Dumbledore.  That is of course if we accept that Minerva McGonagall in the movie is the same Minerva we know. So it seems that he taught Transfiguration, then for some reason switched to DADA and then to Transfiguration again. While it is possible in general, is there any explanation for the reasons? When scripting in bash or any other shell in *NIX, while running a command that will take more than a few seconds, a progress bar is needed.  For example, copying a big file, opening a big tar file.  What ways do you recommend to add progress bars to shell scripts? Resistor in series needed with LED string? A pitcher contains $X + 1$ blue balls and $Y + 1$ red balls. It is known that $X, Y$ are independent random variables, and it is given that $X \sim \mathrm{Poisson}(n), Y \sim\mathrm{Poisson}(2n)$. Calculate the limit: $\displaystyle\lim_{n\to \infty}\mathbb P (X + n = Y) $   I tried to condition on the value of $Y$ and to use the Law of total probability but it did not lead to a solution. ( I tried to sum: $ \sum_{i=0}^\infty\mathbb P(X+n=Y|Y=i)\mathbb P(Y=i) $ and get an expression that I can calculate its limit as n goes to infinity) Proving that if $A^n = 0$, then $I - A$ is invertible and $(I - A)^{-1} = I + A + \cdots + A^{n-1}$ There are several ideas on hard determinism, but the core seems to be that in an interconnected existence, there can be no "actions" (free will), but only "reactions" (determinism). An action of free will would have to be a separate entity outside of existence, so we'd say it can't occur.   Now fast forward to Joe Schmo the robbing/murdering/rapist.  Joe wasn't born in some infinite bliss utopia, then decided one day to invent the concept of scumbaggery.  He's a product of an incomprehensible number of variables - maybe some are apparent like his dad was a violent alcoholic or whatever, but most likely it's far more complicated than that.    So that's fine - I get all that - but if that's the case, then how can you ethically deal with people like that?  You can't hardly let them do what they please at the expense of society, but then how can you get medieval on them when they're basically riding a wave?  I think that's a big reason why people fight concepts of determinism that mitigate or eradicate the concept of free will - now everyone has a license to do what they want and how can you punish them, it's not their fault!  How would/could/should you consolidate hard determinism with responding to criminal acts?