So I have a property in a class called 'tiles' which contains information about a checkers board game's state. I'm trying to push this property to an array called 'moves' every time I make a legal move and at the start of the game. But the problem is, every time I push the new tiles property, the previous elements in the moves array change to the values of the latest pushed tiles.  I understand this is happening because the object is being passed by reference and hence replaces old elements in array because they now point to the same object, which is the latest value of the property tiles. So with my code given below, is there a way I can push this object not by reference but each different individual state of 'tiles' that resulted due to legal moves.  Here is my snippet: App.js    App = function () {   var self = this;   self.tiles = [];    // this is populated with objects from a json file   //code to fetch json and save it to self.tiles   //more code    this.startGame = function () {     //other code     self.moves.push(self.tiles);   };   this.makeMove = function () {     //other code     self.moves.push(self.tiles);   }; };   So what I expect is in self.moves array, the tiles should point to different objects instead of the same object. It should contain different states of self.tiles but right now, as I push the property, the elements of 'moves' array is overwritten by the latest self.tiles value.  Any help to solve this problem will be highly appreciated. Thanks!
What is the most efficient way to clone a JavaScript object? I've seen obj = eval(uneval(o)); being used, but . I've done things like obj = JSON.parse(JSON.stringify(o)); but question the efficiency.  I've also seen recursive copying functions with various flaws.  I'm surprised no canonical solution exists.
Prove that $i^i$ is a real number I was doing some practice problems that my professor had sent us and I have not been able to figure out one of them. The given equation is:  $-y^2dx +x^2dy = 0$  He then asks us to verify that:  $ u(x, y) = \frac{1}{(x-y)^2}$  is an integrating factor.   I multiplied through to get:  $\frac{-y^2}{(x-y)^2}dx + \frac{x^2}{(x-y)^2}dy = 0$   However, the partial derivatives of these do not equal each other so I am a bit confused... Array initialization syntax when not in a declaration why can't `_` be exported to the environment of bash? In bash, why can't _ be exported to the environment of the shell?  $ export _ $ export | grep _= $   output nothing. Or do I miss something?   How can I export _ into the environment?  See also . Thanks. Intuitive understanding of the derivatives of $\sin x$ and $\cos x$ One of the first things ever taught in a differential calculus class:   The derivative of $\sin x$ is $\cos x$. The derivative of $\cos x$ is $-\sin x$.   This leads to a rather neat (and convenient?) chain of derivatives:   sin(x) cos(x) -sin(x) -cos(x) sin(x) ...   An analysis of the shape of their graphs confirms some points; for example, when $\sin x$ is at a maximum, $\cos x$ is zero and moving downwards; when $\cos x$  is at a maximum, $\sin x$ is zero and moving upwards.  But these "matching points" only work for multiples of $\pi/4$.  Let us move back towards the original definition(s) of sine and cosine:  At the most basic level, $\sin x$ is defined as -- for a right triangle with internal angle $x$ -- the length of the side opposite of the angle divided by the hypotenuse of the triangle.  To generalize this to the domain of all real numbers, $\sin x$ was then defined as the Y-coordinate of a point on the unit circle that is an angle $x$ from the positive X-axis.  The definition of $\cos x$ was then made the same way, but with adj/hyp and the X-coordinate, as we all know.  Is there anything about this basic definition that allows someone to look at these definitions, alone, and think, "Hey, the derivative of the sine function with respect to angle is the cosine function!"  That is, from the unit circle definition alone.  Or, even more amazingly, the right triangle definition alone.  Ignoring graphical analysis of their plot.  In essence, I am asking, essentially, "Intuitively why is the derivative of the sine the cosine?" Sometimes we assume that regressors are fixed, i.e. they are non-stochastic. I think that means all our predictors, parameter estimates etc. are unconditional then, right? Might I even go so far that they are no longer random variables?  If on the other hand we accept that most regressors in economics say are stochastic because no outside force determined them with some experiment in mind. Econometricians then condition on these stochastic regressors.  How is this different from treating them as fixed?  I understand what conditioning is. Mathematically, it means we make all observations and inference conditional on that particular set of regressors and have no ambitions to say that inferences, parameter estimates, variance estimates etc. would have been the same had we seen a different realization of our regressors (such is the crux in time series, where each time series is only ever seen once).  However, to really grasp the difference between fixed regressors vs. conditioning on stochastic regressors, I am wondering if anyone here knows of an example of an estimation or inference procedure that is valid for say fixed regressors but breaks down when they are stochastic (and will be conditioned on).  I am looking forward to seeing those examples! To prove in a Group Left identity and left inverse implies right identity and right inverse Let $G$ be a nonempty set closed under an associative product, which in addition satisfies :      A. There exists an $e$ in $G$ such that $a \cdot e=a$ for all $a \in G$.      B. Given $a \in G$, there exists an element $y(a) \in G$ such that $a \cdot y(a) =e$.      Prove that $G$ must be a group under this product.   Attempt -Since Associativity is given and Closure also, also the right identity and right inverse is given .So i just have to prove left identity and left inverse.  Now as $ae=a$ post multiplying by a, $aea=aa$. Now pre multiply by a^{-1} I get hence $ea=a$. And doing same process for inverse Is this Right? SQL Server 2014 - Strange SP behavior during compilation Time Dilation When In Orbit Imagine a space ship orbiting the sun at near relativistic speeds, when compared to Earth (say from the reference frame of the sun) there would be x amount of time dilation.  This would mean people on the ship could live for 100's of Earth years.  My question is what would happen if a second ship flew directly away from the Sun and back (ignoring acceleration) at the same speed the orbiting ship is travelling, would the time dilation for the ship that travels in a straight line be the same as that moving in a circle?  The reason I ask is that I was imagining a scenario where intergalactic travel is possible as time dilation means even a journey of light years only ages the crew a fraction of that time, with space stations orbiting certain star systems at similar speeds so that people that don't work on ships can live a similar length of time. I understand that time dilation is all linked to a certain reference frame but working with a reference frame of the sun what would the time dilation be for the different objects taking different paths but at the same speed relative to the sun? If the ship docked back with the space station would they both say the same amount of time had passed? I am using natbib and agsm for harvard-style referencing. My related code is  \usepackage{natbib} \bibliographystyle{agsm}   Then I am using \citep{} for citations. My problem is that in text I am getting     (Author et al. 2012)   but and I want     (Author et al. 2012)   Does anyone know how to change this and get 'et al' in italics in the text?  I am using TexPad and BibDesk and I have not been able to find the .bst files in Terminal.  I know that it is often correct to have the 'et al.' unitalicised but my university regulations requires italics. How many square meters "twenty feet square" is? One would assume it to be about 2 square meters, but this is obviously not the case. In fact, I'm reading Illium by Dan Simmons. A quote follows:     Much like the room they had faxed into, this space was windowless and about twenty feet square. But unlike the other room, this one was warm, lighted, and free of snow or ice. And unlike the other room, this one was almost filled with an oval metal machine about fifteen feet long.   By this description, "twenty feet square" seems to mean 20x20 feet aka 400 square feet or 40 square meters. Given that Dan Simmons is a renowned American writer, it's not likely that he just can't speak English correctly. So, who's right and who's wrong here? Calculate the uncertainty in velocity of electron I got this question in one of my periodic test in coaching, I (seemingly) solved the question but later recognised what mess I did.  So, the question is :      Calculate the uncertainty in velocity of an electron. If the uncertainty in its position is ${10^ {-15}} \; \mathrm m$.   By simple calculations one can see that the answer would be ${5.79\times{10^{10}}} \; \mathrm{m/s}$. However, as one can see, the uncertainty in velocity is greater than the velocity of light then how is that possible or there is some other way to handle such problems.  P.S. I know the concept of dynamic mass but I am not very familiar with it. (I think that would work here, but don't know how?) Is it possible to add subtitles of a figure which contains subfigures I have a single image which contains two sub-images. I want the following subtitles (a) and (b) to be shown correctly.   In which, left sides is my current image which contains two rectangular. And right sides is my expected result. I found a solution is that we can use subfig package. However, it requires separating the original figure into two subfigure. In that question, I am regarding that we do not need split original figure, I want to write (a),(b) directly below figure. Thanks Current solution is  \begin{figure}[H] \captionsetup{labelfont={bf}}   \centering     \subfloat[]{\centering\includegraphics[scale=0.5]{Fig1a.png}} \\     \subfloat[]{\centering\includegraphics[scale=0.5]{Fig1b.png}}   \caption{This is main figure}   \label{fig:9} \end{figure} I googled it but I couldn't find the answer... maybe I didn't seek it in the proper way. My question is if &quot;to&quot; must be repeated in sentences such as the following ones:   In the past, women used to do the housework and to take care of children.  The aim of this meeting is to control their progress and to discuss the new working plan.    If I had to bet, I would omit the second to... But I am not sure about it. Tikzexternalize not compatible with Miktex 2.9 abntex2 package How do I fix the GPG error "NO_PUBKEY"? Rule of thumb for number of bootstrap samples I wonder if someone knows any general rules of thumb regarding the number of bootstrap samples one should use, based on characteristics of the data (number of observations, etc.) and/or the variables included? Every time I open a folder from the desktop, a prompt is shown that the said folder is opened. How do I stop that? Windows 10 default programs keep changing Since the fall update last month, Windows 10 automatically keeps changing the default apps for certain types (mostly browser,pdf,mp3,jpg). I have tried changing them back from the Settings app as well as the Control Panel.  I have observed that this happens mostly while unzipping files using WinZip. Windows changes the default programs back to Microsoft recommended programs such as Edge, Photos, Groove etc.  Is there a way to restrict this from happening? Has anybody else encountered a similar situation? I couldn't find similar question anywhere so I'm asking this here. I need to know a word which means:     "negligence shown by a person in performing a duty, or a responsibility, or any given task."   or,      "A person who is negligent in performing their duties/responsibilities."   One possible choice is the use of word "delinquent". Is there any other word?  Please provide the usage of suggested word in a sentence also.