In my program, I have 2 objects, A and B, with some code like this:   var a = {"color":"blue"}; var b = a; a.color = "orange"; console.log(b.color);    By setting B to A, they point to the same memory, and I don't want them to do that. I thought of running a for loop of all the keys and values, setting them individually to B, but there's got to be a better way. Any ideas?
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.
How to invite friends to Stack Overflow, Server Fault and Super User? Since we're all into this OpenID thing, I think it would be really useful (and quite easy) to implement a friend invitation feature that grabs a list of friends from one's webmail contact list with an option to choose who to invite to SO, SF or SU. Something in the line of Facebook's friend invitation and recommendation feature. What causes an electric shock - Current or Voltage? Though voltage and current are two interdependent physical quantity, I would like to know what gives more "shock" to a person - Voltage or Current? In simple words, will it cause more "electric - shock" when the voltage is high or Current is more? How do I access $HOME/storage Termux directory on Android Pie with a GUI File Explorer?  In Termux I print the working directory with pwd and it shows $HOME/storage as:  /data/data/com.termux/files/home   My internal storage looks like this:  . ├── Alarms ├── Android |   ├──data |   |  ├── ... |   |  ├── com.termux |   |  |   └── files |   |  |       └── 0 items |   |  └── ... |   └── ... ├── DCIM ├── Download └── ...   My external storage looks like this:  . ├── Android |   ├──data |   |  ├── ... |   |  ├── com.termux |   |  |   └── files |   |  |       └── 0 items |   |  └── ... |   └── ... └── LOST.DIR   Neither my internal storage, nor my sd card, contain a /data/ directory at the root level. Where is this /data/ directory? For that matter, where is the root /storage/ directory? Where is the root /emulated/ directory? Where are any of these directories and why cant I access any of them? Are we slightly lighter during the day and slightly heavier at night, owing to the force of the Sun's gravity? Using $g = \frac{Gm}{r^2}$, the force on a point mass located at 1 AU from the Sun ($m = 2 \cdot 10^{30} \text{ kg}$) is about ~0.006 N/kg.  Does that mean that, e.g., a 70 kg person is ~42g lighter during the day, and ~42g heavier at night? That seems like it could make a big difference for things like measuring gold bars or other weight-sensitive items. (Gold arbitrage: buy your gold during the day and sell it during the night! Risk-free profit!)  This makes me suspect that I'm overlooking something obvious, because a ~0.05% weight difference seems like something everyone would have noticed long ago. So what am I missing?    Edit: A few answers below indicate that there shouldn't be any weight difference, because the Earth orbits the Sun in free-fall. But if that's the reason, does that mean that a 1:1 tidally-locked Earth-Sun system wouldn't experience differential gravity from the Sun on opposite sides? That doesn't seem right. A word for a worldly wise person who pretends to be naïve? What is a word for someone who is experienced and wise, but who deliberately acts naïve?    I don’t intend it for sarcastic use; I’m trying to describe someone succeeding in making people think that that person truly is naïve.   Is there a word for this? How to install Ubuntu 18.04 alongside Windows 10 From what I understand, the frequency of light coming from the source moving towards an observer increases. From $ E=hv $ , this implies increase in energy of photon.  What really is confusing, is where does that extra energy come from? And also where is the energy is lost during opposite Doppler effect (red shift)? Why doesn't this violate the conservation of energy? I am new to Linux and I have Ubuntu 17.04 64-bit (Budgie).  I cannot open steam. It is updated to latest version. When I open it it pops up but after some time it disappears. When I try to run it from a terminal I get this output:  tar: This does not look like a tar archive xz: (stdin): File format not recognized tar: Child returned status 1 tar: Error is not recoverable: exiting now find: ‘/home/ghazi/.steam/ubuntu12_32/steam-runtime’: No such file or directory Showing that $G$ is a group under an alternative operation. Good tools for drawing schematics I was going to add a bit of information to my post on a previous day using schematics and some instructions. What programs are being employed for this purpose?  I mostly want to see what others are using and that I can easily use to give descriptive schematics.  In a perfect world, and I know this is a case of me wishing, it would be:   Free. Extremely easy to draw schematics in. Allows simple production of waveforms for the inputs/outputs. Random operators Let $(\Omega, \mathcal F,P)$ be a probability spaces and $H$ be a Hilbert space. By a random operator $A$ from $H$ to $H$ we mean a linear continuous mapping from $H$ into the Frechet space $L_0^H (\Omega, \mathcal F,P)$ of all $H$-valued random variables. My question is: How Can we define $|A|$ and the adjoint $A^*$? Typically, to box in some text, I use the following:  \fbox {     \parbox{\linewidth}{     This is some text! Blah blah blah...     } }   However, say I have a verbatim block within that. It will never compile. Anyone know how I could draw a box around text which contains a verbatim block? I should note that I want to be able to draw a box around not just a verbatim block. For example, I would want to draw a box around something like:  This is text. \begin{verbatim} This is some more text. \end{verbatim} And this is even more text. Could we please be a bit nicer to new users? There is a distinct decline in the level of civility on all the sites here.  Some of this is due to new users coming in and posting spam and other nonsense, but the off-topic and downvote buttons are doing a pretty good job of keeping this under control. Unfortunately, a lot of this is coming from more experienced users, and the site's built-in moderation system does not (and probably cannot) handle this very well.  Folks are rushing to pound new users down with &quot;this belongs on meta!&quot;, &quot;this is off topic&quot;, &quot;this is a duplicate!&quot; and &quot;read the Help!&quot;. (Which is correct, but should be done nicer) All this, of course, is accompanied by a flurry of downvotes.  This is not very welcoming to new users who don't know about meta, the Help, or what counts as off-topic. Now I am not proposing that we just allow off-topic, meta, or duplicate questions.  However, I think we could be gentler in the way we express these sorts of things.  Explain what meta and the FAQ are and provide useful links.  Just using please and thank-you when asking folks to read the FAQ or post something on meta would be an improvement.  I also think we could rein in the downvoting a bit.  Not that we shouldn't vote stuff down, but unless a new user's post is clearly spam, voting it down to -1 or -2 should be sufficient to send a message without piling on. I like Stack Exchange and I want it to become a resource for everyone, not just an elitist site for high-rep users on the sites. I am trying to slice up my models using the Boolean modifier.  After applying the modifier on my smooth mesh, I get the expected result, a flat dissection to separate my mesh into two.  The problem lies in how I can resolve the visual "jaggered" edge that separates my (smooth) mesh exterior from the flat dissection face.    Is it possible to achieve a smooth-to-flat variation without this artifact?   I tried to alter a mixture of the two but end up with artifacts, or unwanted blocky flat mesh faces around the dissection edge of my mesh. What's the difference between the server version and the desktop version? What's the difference between the server version of Ubuntu and the desktop version? A large number of variants of this question were already asked here, including these - , , which are close, but none seem to answer my question. Assume that $n$ balls are thrown randomly and independently into $k$ bins.  What is the probability of finding $x$ empty bins? What is the expectation of the number of empty bins? Did the date of Frodo's rescue out of the fire of Mordor have any particular meaning in The Lord of the Rings? Did the date of Frodo's rescue out of the fire of Mordor have any particular meaning in The Lord of the Rings?  We read in The Return of the King (Book 6 Chapter 4) that Gandalf states to Frodo and Sam:     The fourteenth of the New Year, or if you like, the eighth day of April in the Shire reckoning. But in Gondor the New Year will always now begin on the twenty-fifth of March when Sauron fell, and when you were brought out of the fire to the King.   Did Tolkien have any particular reason for choosing this date for Sauron's fall and Frodo's rescue out of the fire of Mordor, either allegorically or otherwise?  We are aware that Tolkien was not a fan of , but preferred the term applicability instead. I'm trying to prove  the following claim:     If $f$ is continuous  and $\displaystyle\int_a^\infty |f(x)|\;dx$ is finite then $\lim\limits_{ x \to \infty } f(x)=0$.   Here the counter example of all these sine functions won't do, since  their infinite integral does not converge absolutely.   Any hints for a proof? How to relate areas of circle, square, rectangle and triangle if they have same perimeter?? I was given a question which was like:     Suppose that a circle, square, rectangle and triangle have same perimeter. How area their areas related??   My work:  I broke the question in parts and tried to prove it seperately:  STEP $1$. Suppose the given perimeter is $P$.So the radius of circle will be ${r=P/2\pi}$.  And hence area of the circle will be:   ${P^2/4\pi}$.  Side of square will be $P/4$ and hence area of square will be $P^2/16$.   It is obvious that ${P^2/4\pi}$  >  $P^2/16$.   So Area of circle is more than area of square.  STEP $2$: Whether by using $AM&gt;GM$ inequality or by using a bit of differentiation, we can get that product off two quantities is maximum when they are equal.  So, Area of square is more than Area of rectangle.  Here, the hardest part come (at least for me). I can't relate the area of triangle to any of Circle, Square or Rectangle. It would have been easy if the triangle was Equilateral, Right angle but the question is talking about a general triangle.  However, when I considered the situation with different examples (Assuming the perimeter and calculating the area, I got the relation:  Circle > Square > Rectangle > Triangle.  I shall be highly thankful if you guys can establish the relation in purely mathematical way.  EDIT: This question does not ask that whether circle have the largest area among all 2-D figures or not. The OP just want to relate the areas of Circle, Square, Rectangle, Triangle in a pure mathematical way. If A and B are correlated with C, why are A and B not necessarily correlated?