For some strange reason, when this data:  // data visitorsTemplate: [{   text: '',   type: 'buttons',   children: [{     name: 'email',     method: (e) =&gt; { this.sendEmail(e) }   }] }]   Is cloned:  // watch console.log(this.visitorsTemplate) const visitorItem = clone(this.visitorsTemplate) console.log(visitorItem)   With this function:  // utils export const clone = (...args) =&gt; {   return JSON.parse(JSON.stringify.apply(null, args)) }   the method attribute disappears. Here are the console.logs:  [{   text: "",   type: "buttons",   children": [{     name: "email",     method: f method(e)   }, {     name: "delete",     method: f method(e)   }] }]  [{   text: "",   type: "buttons",   children": [{     name: "email"   }, {     name: "delete"   }] }]   Update: I found out JSON.stringify is removing the methods but I need to create a new array. So how to avoid removing the methods?
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.
What do you recommend as an optimal point and orientation for mounting a rear-view mirror? I'm open to handlebar-, glasses-, or helmet-mounted.  Some of the considerations, as I understand it, are:   Ease of mounting. View provided. Vibration. Likelihood of breaking. Robustness for repeated off and on (for glasses-mounted).   I've got a hybrid bike with flat handlebars.  I'd also welcome specific product recommendations and recommendations about other aspects to look for in a mirror. When should you use generator expressions and when should you use list comprehensions in Python?  # Generator expression (x*2 for x in range(256))  # List comprehension [x*2 for x in range(256)] When is JavaScript's eval() not evil? I'm writing some JavaScript code to parse user-entered functions (for spreadsheet-like functionality). Having parsed the formula I could convert it into JavaScript and run eval() on it to yield the result.  However, I've always shied away from using eval() if I can avoid it because it's evil (and, rightly or wrongly, I've always thought it is even more evil in JavaScript, because the code to be evaluated might be changed by the user).  So, when it is OK to use it? How do I suppress the whitespace above an equation block at the page top? How do I suppress the whitespace above the equation block at the page top ? It is added to the top margin, and I don't want that to happen. I know that \abovedisplayshortskip controls this for the whole document, but how can I change this for this particular equation block and NOT for any others ? Negative vspace doesn't work.  \documentclass[pdftex,12pt,a4paper,english,dutch,leqno]{article} \usepackage[top=1cm,right=1cm,bottom=1cm,left=1.5cm,noheadfoot]{geometry}         \usepackage{babel} \usepackage{amsmath} \usepackage{amssymb} \usepackage{empheq}  \begin{document}  \abovedisplayskip=6pt \abovedisplayshortskip=3pt % This should NOT be changed \belowdisplayskip=6pt \belowdisplayshortskip=3pt  \begin{equation*} \left.\begin{array}{r} a_{31}'=a_{11}\cdot a_{31}-a_{31}\cdot a_{11}=0\\ a_{32}'=a_{11}\cdot a_{32}-a_{31}\cdot a_{12}\\ a_{33}'=a_{11}\cdot a_{33}-a_{31}\cdot a_{13}\\ a_{34}'=a_{11}\cdot a_{34}-a_{31}\cdot a_{14}\\ b_{3}'=a_{11}\cdot b_{3}-a_{31}\cdot b_{1} \end{array}\!\!\right\} \Longrightarrow\; \begin{matrix*}[l] \text{Pseudo-code :}\\ a_{11}\cdot b_{3}-a_{31}\cdot b_{1}\mapsto b_{3}\text{.}\\ \forall\;i\in\{4,3,2,1\} : a_{11}\cdot a_{3i}-a_{31}\cdot a_{1i}\mapsto a_{3i}\text{.} \end{matrix*} \end{equation*}  \end{document} I was wondering why binary crossentropy can be used as the loss function in autoencoders trained on (normalized) images, e.g.  or ? I know that binary crossentropy can be used in binray classification problems where the ground-truth labels (i.e. $y$) are either 0 or 1 and therefore when predictions (i.e. $p$) are correct, in both cases, the loss value would be zero:  $$ BCE(y,p) = -y.log(p) - (1-y).\log{(1-p)} $$  $$ BCE(0,0) = 0, BCE(1,1) = 0 $$  However, binary crossentropy does not have a value of zero when neither of its arguments are both zero or one, which is the case for an autoencoder with ground-truth labels in range $[0,1]$ (i.e. assuming the input data has been normalized in this range). I thought a regression loss function such as mean squared error or mean absolute error must be used instead, which have a value of zero when labels and predictions are the same. What am I missing here? Related questions in "Ask Question" page is better than the search tool The program ed, a minimal text editor, cannot be exited by sending it an interrupt through using Ctrl-C, instead printing the error message "?" to the console.  Why doesn't ed just exit when it receives the interrupt?  Surely there's no reason why a cryptic error message is more useful here than just exiting.  This behavior leads many new users into the following sort of interaction:   $ ed hello ? help ? exit ? quit ? ^C ? ^C ? ? ? ^D $ su # rm -f /bin/ed    Such a tragic waste—easily avoidable if ed simply agreed to be interrupted.  Another stubborn program exhibiting similar behavior is less which also doesn't appear to have much reason to ignore C-c.  Why don't these programs just take a hint? Let $X,Y,Z$ be subspaces of $V$ so that $X$ is a subspace of $Y$. Prove that $Y\cap (X+Z)=X+(Y\cap Z)$ What performance differences are there when installing with Wubi? Is there any way to add an ePub book to iBooks without iTunes? I purchased a book and have it in ePub and PDF formats. I can easily add the PDF to iBooks from Safari. However, I can't find a method to get an ePub book into iBooks without iTunes. I'm away from my laptop with iTunes where my iPhone syncs, so that's not an option at the moment.  Is there anyway to add an ePub book to iBooks without iTunes? I'm using LyX for technical documentation and want to automate the process of creating PDF files.  Within LyX, I can simply click the button "View PDF (XeTeX)", and LyX performs the whole build process for me: it creates a .tex file, does some bibliography magic, and uses XeTeX to create the final PDF file.  What I'm looking for is a way to call LyX from the command line and get the same result. So far, I've only managed to generate a plain .tex file (using --export-to xetex). However, when I run xelatex on the generated file, it keeps showing errors that don't occur when building using LyX. Is there a way to get LyX to do the work?  My system: Windows 7 64bit, LyX 2.1.0 Why can't my subclass access a protected variable of its superclass, when it's in a different package? What is the ultimate postal code and zip regex? I'm looking for the ultimate postal code and zip code regex. I'm looking for something that will cover most (hopefully all) of the world. How to reset Kali linux root password Please explain the meaning of "otherwise than" in this sentence Please explain the meaning of the second part and explain "otherwise than" in part b     a person’s UK property business consists of:      (a) every business which the person carries on for generating income from land in the United Kingdom; and      (b) every transaction which the person enters into for that purpose otherwise than in the course of such a business. Sitemaps - one per subdomain or one for the base domain? I have more than 5 subdomains on a project, say developer, www, staff and some more, what is the best practice in creating sitemaps?   All subdomains that share a same sitemap at base domain (example.com/sitemap.xml) ? or different sitemaps for different subdomains?(developer.example.com/sitemap.xml and www.example.com/sitemap.xml)   Since the subdomains are several parts of the main application, what are the pros and cons of each, and what should I consider while choosing the one over the other? (one sitemap per subdomain or one for the whole site) Shortcut for toggling between different windows of same app? Why are local variables not initialized in Java? Was there any reason why the designers of Java felt that local variables should not be given a default value? Seriously, if instance variables can be given a default value, then why can't we do the same for local variables?  And it also leads to problems as explained in :     Well this rule is most frustrating when trying to close a resource in a finally block. If I instantiate the resource inside a try, but try to close it within the finally, I get this error. If I move the instantiation outside the try, I get another error stating that a it must be within a try.      Very frustrating. Illustrator: how to change the artboard number? Understanding shape and calculation of confidence bands in linear regression