How to properly create a new object that is a copy of another? I recall being able to clone an object with the spread operator like such:  let obj1 = {   key: 'value',   key2: 'value2'   }  let obj2 = { ...obj1 }   But now I realize this doesn't work as I am trying to change values of obj2 and its also changing the values in obj1.  If I did:  obj2.key2 = 'test'   It would change obj1.key2 to 'test' as well.  Why is this happening?  I also tried doing:  let obj2 = Object.assign({}, obj1)   but i face the same issues.  Thanks  let obj1 = {   key1: 'value1',   key2: 'value2' }  let obj2 = { ...obj1 }  obj2.key2 = 'changed key2 value'  console.log( obj1.key2 == obj2.key2 )
What is the most efficient way to deep clone an object in JavaScript? 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.
Unknown Syntax Error in Code So, I am following a , and it is using Python code to create an audio visualizer in Blender. Now, I've always been a coding geek, but I don't actually know Python. I've taken a few shots at it but overall, I don't know Python, however, I can read and understand the code because I know basic programming concepts. Now, I'm following this tutorial as closely as I can (the tutorial does not provide code to copy and paste) and I am getting a syntax error. As far as I can tell, there is no syntax error. The line of code (specified by the error message) appears perfect. This line of code is supposed to set the 3D cursor to the active object's origin. Here's the catch: if I run that exact same line of code in the console, it executes just fine. So here's the error message I get:  File "C:\Me\Blender\Blender Projects\audio visualisation.blend\AudioVisualizer", line 17 bpy.context.scene.cursor_location = bpy.context.active_object.location    ^ SyntaxError: invalid syntax location: &lt;unknown location&gt;:-1   It tells me to look in the console for error message, but the console doesn't output anything.    Thanks!  EDIT: Alright. I've tried all the examples and all the procedures that have been suggested by you guys, but it keeps feeding me errors. According to the console, one of the problems it is spitting out is in C:\Program Files\Blender Foundation\Blender\2.74\scripts\modules\bpy\ops.py. This makes me think there is a bug in the API that is causing one of the many errors. EDIT: Here are the error messages I get for my code. Original Code:  Error:   File "C:\Gannon\Blender\Blender Projects\audio visualisation.blend\Audi o Visualizer", line 35     bpy.ops.graph.sound_bake(filepath="C:\Gannon\Blender\Sounds\Music\Batty McFa dden.mp3", low=i*step high=i*step+step                           ^ SyntaxError: invalid syntax    gandalf3's Code and zeffii's Code are essentially the same with alternative formatting which changes the line numbers where the error occurs.  Error: Unsupported audio format  Traceback (most recent call last):   File "C:\Gannon\Blender\Blender Projects\audio visualisation.blend\Audio Visua lizer", line 42, in &lt;module&gt;   File "C:\Gannon\Blender\Blender Projects\audio visualisation.blend\Audio Visua lizer", line 35, in spiral   File "C:\Program Files\Blender Foundation\Blender\2.74\scripts\modules\bpy\ops .py", line 189, in __call__     ret = op_call(self.idname_py(), None, kw) RuntimeError: Error: Unsupported audio format I would be happy to get some hints on the following integral: $$ \int_0^1\frac{x^{19}-1}{\ln x}\,dx $$ How many ways can $r$ nonconsecutive integers be chosen from the first $n$ integers? During self-study, I ran across the question of how many ways six numbers can be chosen from the numbers 1 - 49 without replacement, stipulating that no two of the numbers be consecutive.  I can obtain a simple lower bound by saying that, in the worst-case scenario, when you choose a particular number, there are now three numbers that cannot be chosen next.  For example, if I first pick 17, then I can't choose 16, 17, or 18 for the remaining choices.  This gives me the lower bound  $$\frac{49*46*43*40*37*34}{6!} = 6,773,770 \frac{8}{9}$$  This is about 48% of ${}_{49}C_6 =  13,983,816$.  The real answer must be bigger (and an integer).  I haven't found a way to calculate it, though.  The original problem asked to show that the probability of having non-consecutive integers when you choose six is greater than 50%, so if the problem is complicated to count exactly, better approximations that show the answer is above 50% would also be appreciated.   Of course, I can use a computer to do the counting, but I'm interested in learning what methods I'm missing. Removable singularities and an entire function Function $f(z)$ is an entire function such that $$|f(z)| \le |z^{n}|$$ for $z \in \mathbb{C}$ and some $n \in \mathbb{N}$.  Show that the singularities of the function $$\frac {f(z)}{z^{n}}$$ are removable. What can be implied about the function $f(z)$ if moreover $f(1) = i$? Draw a far-reaching conclusion.  My attempt: If the singularities of $\frac {f(z)}{z^{n}}$ are removable, it is entire (not sure, need help with the justification) and bounded, so constant from Liouville's theorem, the constant value of the funcion is $i$, hence $f(z)=iz^{n}$.   But what about the $n$ here, is it arbitrary? Could somebody help me prove the removability of the singularities and suggest if my attempt is going the right way? How do I write a URL in Markdown on Stack Exchange? Do we need inertial frames in Lagrangian mechanics? su command + authentication failure I am having problems with the su command. I know my password and I am typing it correctly but su indicates authentication failure.  So I checked on the internet and then went into recovery mode and changed my username's password to what I was entering before.  Even now entering the same password on su gives me authentication failure.  Please suggest what am I doing wrong?? There's a problem statement:     For each $m \in \mathbb{N}$, we construct a sequence $m_0$, $m_1$, $m_2,\dots$ denoted $S_m$, recursively via $m_0=m$ and      $$m_{i+1} = m_i + \left\lfloor \sqrt{m_i} \right\rfloor$$      for all $i \ge 0$.   Here, $\lfloor x \rfloor$ is the floor of $x$, the greatest integer less than or equal to $x$.   Hence, we have $\left\lfloor \sqrt{10} \right\rfloor=3$ and $\left\lfloor \sqrt{29} \right\rfloor=5$.      Show that for each positive integer $m$, the sequence $S_m$ contains the square of some integer.   I'm pretty certain that this can be proved with induction. I am just not quite sure what to induct on. Examining examples shows that $S_m$ always results in a perfect square eventually, though I'm not sure how to prove it. Using 'for' as a coordinating conjunction at the beginning of a sentence – is this acceptable? As I understand it, 'for' is a coordinating conjunction. Learning German as a second language has taught me specifics about reforming sentences, but it is an awful lot less common in English. If I were to rearrange the sentence: "I ate lunch, for I was hungry," so that 'for' was the first word of the sentence, by my reckoning I should end up with "For that I was hungry, I ate lunch." Does this new sentence have any grammatical errors? I inserted the word 'that' after 'for', because without it the sentence didn't sound right. Should I have? Is there a rule for that? Thank you in advance, an aspiring author.  Additional Information:  I am not having problems with the sentence, this is a general question to increase my knowledge of the manipulations of coordinating conjuntions. Unable to get force:inputField or force:outputField to render inside other markup in Lightning Component when used in Lightning Experience Disable Ctrl+Alt+Del on Windows 7 I was trying to solve internet problems, and seem to have made things worse: Now when I start the computer it gets stuck on "Booting system without full network configuration".   Does anyone know how to make it unstuck?   Alternatively: It got messed up when I changed the contents of /etc/network/interfaces, so presumably would work again if I changed it back. How can I edit this file during boot?   I'm using Ubuntu 12.10. Connecting multiple screens to the 2016 MacBook Pro with Touch Bar I'm thinking about buying the new MacBook Pro with 4 USB-C ports.  I want to attach two screens, mouse and keyboard and ethernet to the MacBook Pro while using the fewest number of USB-C ports possible.  So what I need is an adaptor with:   two DP or HDMI ports (or one DP port with daisy chaining support) two or more USB ports an ethernet port   Best case would be a hub to which all devices are connected with a single connection to the MacBook Pro, including power supply. Worst case if attaching the MacBook Pro to the devices would require me to use all four of USB-C ports.  Given the answers up to far, I can tell that:   Daisy chaining might or might not work with the MacBook Pro (since it requires DP1.2 which is supported by the graphics chipset, but it's uncertain if it's supported by the MacBook Pro itself) I can attach the monitors with two cables as a last resort, leaving me with two ports for the remaining peripherals.   What I still don't know:   Would daisy chaining work with a hub or does it require the first monitor to be directly attached to the MacBook Pro? Does some kind of hub exist supporting attachment of all listed devices with a single upstream connection to the MacBook Pro? iCloud says Password is Wrong Even Though I Know It's Right iCloud says that my password is wrong - even though I know it's right.  Here's whats happened: Yesterday, I reset my iCloud password. Got the reset email, changed password. Tried to log in to the account, didn't accept it. I thought that maybe my finger had slipped typing in the password (twice). I called support, got the reset email.  Now, here's the really, really weird thing: I wanted to make sure I got the password right - so I typed my password into TextEdit, copied it into the reset fields and reset the password. After reseting it, I immediately went to icloud.com and tried to log in using the copied password from TextEdit. The passwords are the same. iCloud won't let me in. In an hydrogen-like atoms the orbitals are solutions to the Schrodinger equation suitable for the problem.  They describe the regions where an electron can be found.  So, why don't they have spherical symmetric?  As in this picture:    Why, in a certain distance from the nucleus, are there points where an electron can be found, and points where it can't?  EDIT: Is there any intuation about the symmetry breaking? What happens with excess items if my bag is full, and what should I do to avoid losing items? There's a default limit of 350 items in the bag (even though you can expand it through the shop). I am currently level 6 and have already ~250 items in my bag. I haven't done any battles yet, as all the gyms in my area are too strong for my pokémon at the moment. So I have a lot of Pokéballs, Heals and Revives that I don't need right now.  What happens once my bag is full? Will additional items go into a temporary overflow bag? Will I just lose them? Will they replace older items?  I'm afraid I will lose the valuable items gained through a level-up. Should I throw away items to avoid that? If so, what should I throw out first? Heals and Revives, as I don't need them right now? Or will they become too valuable later on and I should rather throw out some Pokéballs as those are the most common items to receive from a Pokéstop?  TL;DR: What happens with items that exceed my bag size limit and what is the best strategy to avoid losing valuable items? Why does `last` show '{' and '|' in the TTY field? How can I avoid asking duplicate questions? Is there any clever method out there to make my executeEveryDayMethod() execute once a day, without having to involve the Windows TaskScheduler? remote ssh tcpdump command, through a gateway, to be opened, in realtime, in Wireshark, on local machine I (Host A - Windows based using plink) am trying to connect to a remote linux server (Host C), through a gateway linux server (Host B), and run this tcpdump on Host C to be piped all the way back to Host A (through Host B I assume), and opened, in real time, with Wireshark on Host A:  Below is what I saw as the command when not using a gateway ("direct remote fetch").  So, how would I make this work going through my gateway host B scenario above?  Host A$ plink.exe -ssh -pw abc123 root@Host C "tcpdump -s0 -U -n -w - -i eth0 not port 22" | "C:\Program Files\Wireshark\Wireshark.exe" -k -i -