Javascript proxy, reference type versus value type I am trying to find an explanation for behavior with - what I expected to be - a reference type but actually loses reference once supplied as an argument. Any changed made on the property are not reflected on the original object. When I provide the full object, and make changes it gets noticed by the proxy. When I provide the property and make changes it doesn't get noticed. I've done my fair share of javascript code but this one is pretty confusing. Normally I have to really do a JSON.parse((JSON.stringify(foo)) to make a deep copy and really get rid of any reference but this time I really only wanted to provide the property to the object as an argument and avoid sharing the entire object as an argument. I have build a test case that shows exactly what is happening. &lt;html&gt; &lt;head&gt;&lt;title&gt;&lt;/title&gt;&lt;/head&gt; &lt;body&gt;  &lt;script&gt; var state = {}; state.Foo = 'default value for Foo';  function TwoWayBinding(state) {     this.state = this.WrapWithProxy(state); } TwoWayBinding.prototype.WrapWithProxy = function (state) {     const handler = {         get: function(target, prop) {             return target[prop];         },         set: function(target, prop, value) {                  console.log(prop,value);                     target[prop] = value;              return true;         }     };     return new Proxy(state, handler); }; var twoWayBinding = new TwoWayBinding(state); state = twoWayBinding.state;   function Test(fooProperty,fullState){     fooProperty = &quot;changed value A, check console&quot;; // fails     fullState.Foo = &quot;changed value B, check console&quot;; // works          // additional tests     this.state = fullState;     this.test = this.state.Foo; // breaks reference     this.state.Foo = 'changed value C, check console'; // works     this.test.Foo = 'changed value D, check console'; // fails }  new Test(state.Foo,state);  &lt;/script&gt; &lt;/body&gt;
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?
How slow are .NET exceptions? I don't want a discussion about when to and not to throw exceptions. I wish to resolve a simple issue. 99% of the time the argument for not throwing exceptions revolves around them being slow while the other side claims (with benchmark test) that the speed is not the issue. I've read numerous blogs, articles, and posts pertaining one side or the other. So which is it?  Some links from the answers: , , . Can I look at the upgrade log after a distribution upgrade? I've upgraded to Ubuntu 12.04 and did it . I didn't look at the "packages to remove" section before clicking next - I've done Ubuntu upgrades many times and assumed it was just the normal set of obsolete library packages etc. But I do tend to watch the terminal text go by and see what it's doing, and I saw it removing a number of packages I wanted. I guess these are packages that aren't on the CD that can't co-exist with the new Ubuntu.  Anyway, I want to find which packages have been removed. So does the update log get saved somewhere?  Then I can start doing some grepping on it and then reinstall the packages I did want. I think I have heard that the following is true before, but I don't know how to prove it:     Let $A$ be a matrix with real entries. Then the minimal polynomial of $A$ over $\mathbb{C}$ is the same as the minimal polynomial of $A$ over $\mathbb{R}$.   Is this true? Would anyone be willing to provide a proof?    Attempt at a proof:  Let $M(t)$ be the minimal polynomial over the reals, and $P(t)$ over the complex numbers. We can look at $M$ as a polynomial over $\Bbb C$, in which case it will fulfil $M(A)=0$, and therefore $P(t)$ divides it. In addition, we can look at $P(t)$ as the sum of two polynomials: $R(t)+iK(t)$. Plugging $A$ we get that $R(A)+iK(A)=P(A)=0$, but this forces both $R(A)=0$ and $K(A)=0$. Looking at both $K$ and $R$ as real polynomials, we get that $M(t)$ divides them both, and therefore divides $R+iK=P$.   Now $M$ and $P$ are monic polynomials, and they divide each other, therefore $M=P$.  Does this look to be correct?    More generally, one might prove the following     Let $A$ be any square matrix with entries in a field$~K$, and let $F$ be an extension field of$~K$. Then the minimal polynomial of$~A$ over$~F$ is the same as the minimal polynomial of $A$ over$~K$. How do I remove extra Skype icon or ghost icons for removed apps from GNOME shell? What does --shell-escape do? I stumbled upon an example, which needed to be compiled with the additional option --shell-escape. Using this option it worked just fine, but I'm curious:     Why or when is this option needed and what does it actually do? Does Reincarnation allows skills to be passed into other classes I'm mainly asking this for Disgaea: Afternoon of Darkness, given I have enough Mana to reincarnate a character into 4 different types of Mages (Green, Blue, Red, Star), a Cleric and then a Warrior, would the Warrior have all the spells learned from the previous classes? What's the typical microclimate in the aircraft passenger cabin? The reply buttons in chat shouldn't reposition themselves on pinged messages Machine Learning - Where is the difference between one-class, binary-class and multinominal-class classification? Where is the difference between one-class, binary-class and multinominal-class classification?  If I like to classify text in lets say four classes and also want the system to be able to tell me that none of these classes matches the unknown/untrained test-data.   Couldn't I just use all the methods that I mentioned above to reach my goal? e.g. I could describe C1, C2, C3 and C4 as four different trainings-sets for binary-classification and use the trained models to label an unknow data-set ...  Just by saying, Training-Set for C1 contains class 1 (all good samples for C1) and class 0 (mix of all C2, C3 and C4 as bad samples for C1).  Is unlabeled-data C1 -> 1 or 0  Is unlabeled-data C2 -> 1 or 0 ... and so on ...  For multinominal classification I could just define a training-set containing all good sample data for C1, C2, C3 and C4 in one training-set and then use the one resulting model for classification ...  But where is the difference between this two methods? (except of that I have to use different algorithms)  And how would I define a training-set for the described problem of categorizing data in those four classes using one-class classfication (is that even possible)?  Excuse me if I'm completely wrong in my thinking. Would appreciate an answer that makes the methodology a little bit clearer to me =) What are weapon damage dice? Following discussion , what constitutes a weapon damage die?  Is it any damage die dealt by the weapon? For example, consider a  longsword.     While the sword is ablaze, it deals an extra 2d6 fire damage to any target it hits.   What are the weapon damage dice? Just the 1d8 from the longsword? Or do the 2d6 Fire damage also count? Origin of "Fits [x] to a T"? The above phrase is something I've known for as long as I can remember, though I don't know from where. What is its origin and usage? Example: &quot;While Android products aren't quite what I need, iOS devices fit my needs to a T.&quot; PostgreSQL check bloating of a table Why does an conditionally convergent infinite series, when deranged, have a different limit? $\sum u_n = 1-\frac{1}{2}+\frac{1}{3}-\frac{1}{4}+\dots$ conditionally converges to $\log 2$; and, when deranged to $\sum u'_n = 1-\frac{1}{2}-\frac{1}{4}+\frac{1}{3}-\frac{1}{6}-\frac{1}{8}+\dots,$ converges to $\frac{1}{2}\log 2$. Why does a deranged conditionally convergent series have a different limit? First Course in Math Anal, p.93, by Burkill, explains that the sums $s_n, t_n$ of the first n terms of the two series are different functions of $n$. This reasoning is incomplete, because different functions of $n$ can converge to the same limit; for example, let $r_n$ be the first $2n$ terms of $\sum u_n$, then $s_n$ and $r_n$ are different functions; besides, by differently defining terms, i.e. clustering pieces of a series, e.g. \begin{align*} 1-\tfrac{1}{2}-\tfrac{1}{4}+\tfrac{1}{3}-\tfrac{1}{6}-\tfrac{1}{8}+\dots = \left(1-\tfrac{1}{2}-\tfrac{1}{4}\right)+\left(\tfrac{1}{3}-\tfrac{1}{6}-\tfrac{1}{8}\right)+\dots \\ = \left(1-\tfrac{1}{2}-\tfrac{1}{4}+\tfrac{1}{3}-\tfrac{1}{6}-\tfrac{1}{8}\right)+\dots,\\ 1-1+1-1+\dots = (1-1)+(1-1)+\dots \\ =(1-1+1-1)+\dots,\\ 1+1+1+1+\dots = (1+1)+(1+1)+\dots \\ = (1+1+1+1)+\dots, \end{align*} one gets the sum of first n terms as different functions, but the series's limit remains. One could view a changed limit from the perspective of the changed number of terms, Denote 'countably many', the size of natural number, as $\lvert\mathbb{N}\rvert$, then $\lvert\mathbb{N}\rvert = \lvert k\mathbb{N}\rvert = \lvert\mathbb{N}\times\mathbb{N}\rvert$. Then two series with different numbers (e.g. $\lvert \mathbb{N}\rvert$, $\lvert k\mathbb{N}\rvert$) of terms– and so having different limits– paradoxically have same number of terms–and so are possibly formed by the same terms. The paradox could be the fundamental reason. Are there other explanations? Is the use here of 'countably many' is proper? What makes a Feynman diagram real or virtual? Simple question: as the title says, what makes a real Feynman diagram real, and what makes a virtual diagram virtual? Or in other words, how do I tell whether any given diagram is real or virtual? I've never gotten a really satisfying explanation of this. I would imagine it has something to do with virtual particles, but all internal propagators are virtual particles and I know for a fact that having internal lines doesn't make a diagram virtual. Email from IOS with attachments larger than 7.5Mb gets stuck in outbox and constantly tries to resend. Costs us hundreds in data fees JSF 2.1 ViewScopedBean @PreDestroy method is not called I have to determine how many six-integer subsets of $\{1, 2, 3, \ldots, 20\}$ are possible if no two consecutive integers are in a set. Why do backgrounded processes sometimes stop spontaneously? Sometimes, some time after I've backgrounded a process with bg in bash, when I press Enter in the same shell to redisplay the prompt (just to check that I'm still in bash when some output from the background process has been displayed), the background process seems to stop spontaneously.  If I do bg again the same problem recurs.  The only way to fix it seems to be fg.  Why does this happen? How to use GROUP BY to concatenate strings in MySQL? If $\alpha_{1},\ldots,\alpha_{m}$ are vectors different from zero vector, then there is a linear functional $f$ such that $f(\alpha_{i})\neq 0$