Can I find a required name without loop through each array item?  Is there any faster way to do the same assuming that I have a very big array length, because if I have an array of 10000 items and the name doesn't exist in it, it will be a waste of time and assuming that we don't have inclouds function     $(document).ready(function() {   function binarySearch(names, requiredName) {     for (var i = 0; i &lt; names.length; i++) {       if (names[i] === requiredName) {         return true;       }     }     return false;   }   console.log(binarySearch(['ola', 'amer', 'anwar', 'mamon'], 'hadeel')); }); &lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"&gt;&lt;/script&gt;
What is the most concise and efficient way to find out if a JavaScript array contains a value? This is the only way I know to do it: function contains(a, obj) {     for (var i = 0; i &lt; a.length; i++) {         if (a[i] === obj) {             return true;         }     }     return false; }  Is there a better and more concise way to accomplish this?
Recently as per this       For individuals who have chosen to receive automatic updates through   Windows Update, we help upgradable devices get ready for Windows 10 by   downloading the files they’ll need if they decide to upgrade.   but Microsoft seems to be downloading hidden update in windows 7 :  according to this  :     An INQUIRER reader pointed out to us that, despite not having   'reserved' a copy of Windows 10, he had found that the ~BT folder,   which has been the home of images of the new operating system since   before rollout began, had appeared on his system. He had no plans to   upgrade and had not put in a reservation request.   As per the above two articles there was hidden update for windows 10 with respective to windows 7 and 8 machines ,whats the effective way to stop this hidden update?  right now i cant disable windows update since i wish to patch my system with latest updates,  i checked the question which was marked as possible  :     inorder to clarify how it differs it talks about the cancelled update   ,but this was latest issue which was araised two days before,i didnt   dig much about that and believe both were different ,apart from that   it was about after the cancellation of update a   nd this one was about preventing such an update from downloading to my pc  any suggestions to avoid this update? What are the best practices for battery longevity? How do you maximize the cycle count of your battery?  There seems to be a debate between:   Leave plugged in 24/7 but do a full cycle once a month Charge to ~100%, drain to ~10%, repeat.   NOTE: Taking your   Which method is better and why? How much of a difference does it really make?  Here are some of the better sources I've found about battery behavior so far. Even still I feel they don't conclusively answer the question above. See my elaborations below:           Elaborating on Option 1  Now IF Apple engineers were smart and optimized for AC draw when plugged in to not use up your charge cycles, then it seem logical to assume that you are using effectively none of your 1000 charge cycles while plugged in. If that's the case, it would seem that the LiPo drop from holding at 100% would be vastly outweighed by the fact you're not using any charge cycles.  However, this is a purely speculative assumption and I could find no evidence to either confirm or deny.  If this is NOT true, and the AC adapter only goes to charging the battery, then there would be no difference. Your battery would drain to 99%, then back up to 100%, then back down to 99%, etc. Those micro-charge cycles would add up at the same rate as 100% -> 0% -> 100%, and you would get no gain. In this case the negative effect of holding LiPo batteries at 100% would outweigh everything else.  Elaborating on Option 2  There are lots of good reasons why Option 2 is the way it is:   Because of known LiPo chemistry issues, holding a 100% charge for a long time causes the battery to degrade Apple specifically recommends not to leave it plugged in all the time  Draining a battery all the way to zero all the time is bad for the cell (Which is why ~10% is used) Heat is a killer, and when plugged in AND charging, you get extra heat that causes damage.   There are a couple reasons why I'm challenging Option 2:   It seems silly that the most intuitive use case for thousands of people that use their macs as primary computers is wrong. If the hypothesis in option 1 is true, you're just burning unnecessarily through your finite charge cycles. It's a pain to have to remember to keep plugging in and plugging out and be worried about whether or not your device is plugged in. Let the ring of fractions be denoted as $S^{-1}R$.       Proposition (from Robert Ash's textbook "Basic Abstract Algebra")      Define $f: R \rightarrow S^{-1}R$ by $f(a) = a/1$. Then f is a ring homomorphism. If S has no zero divisors then f is a monomorphism, and we say that R can be embedded in $S^{-1}R$. In particular:      (i) A commutative ring R cna be embedded in its complete (or *full) ring of fractions ($S^{-1}R$, where S consists of all non-divisors of zero in R).       (ii) An integral domain can be embedded in its quotient field.    Why does the proposition say "If S has no zero divisors..."? If S really had zero divisors, then this wouldn't even be properly defined, right? Because we would have a/0 for some a in R. I am presenting a paper at a computer science conference.  The paper I submitted to the conference mentioned future work that would significantly enhance the utility of the method.  This work was work that was always planned to be part of the same "project" as the work in the paper, indeed the conference paper is presented as a part way step towards doing X, and the future work is what takes it all the way.  The extension was quite involved (and not quite complete when I submitted the paper for review). They day before I left for the conference that work was "completed", in that a journal article about it was submitted for review.  Now when I present at the conference, in the conclusion I want to mention the future work&nbsp;&ndash; at least to the extent that it was described in the conference paper. Should I go into more detail? Should I even mention that "This work is now complete, and is under review for publication"? I just wrote a question before this one and had trouble uploading a screenshot. The drop your image dialog throws no warning or error, but after uploading it won't show.  I also noticed that other questions won't load their images. Could this be some issue with imgur or similar?  Example:     When opening the image in a separate tab, Chrome gives a "too many redirects" error:    This might be linked to I have fought the pumpkin moon and died like 3 times and made it to wave 7 or 6 whenever the pumpking first appears. I have full turtle armor and my primary melee weapon is a demon sickle. I also have the possessed hatchet, magnet sphere, and sniper rifle. I also have other gear like the Uzi. What should I replace, what should I take out, and what should I add? Thanks! Is there a direct download link with a raw data dump of Stack Overflow? (not a torrent) I would like to create a local MySQL copy of Stack Overflow for academic purposes (school project). As far as I know, the database dump of the  database is available only in an XML format that I will have to convert to SQL on my own with some tool.  Most of direct download links I found were broken (404). The only non-torrent source that I have found and that is still alive is  but the latest Stack&nbsp;Overflow dump there is from October 2009, content of which looks like this:    Where could I find a direct download link with the Stack&nbsp;Overflow dump?    Note: I am not able to use torrents due to network policies, yet for the completeness of this question, here's the link that might help someone:    Other related questions / links that haven't helped me:     ~ all links there give 404  ~ from September '09 with another broken link  ~ from about a year ago with a clearbits.net link  ~ also not working anymore I need to show that for any countable ordinal $\alpha$ there is a set A $\subseteq \mathbb{Q}$ such that (A, &lt;) is isomorphic to ($\alpha, \in$).  To do it I am supposed to show the following stronger statement by induction on ordinals $\alpha$ &lt; $\omega_{1}$:  Let P($\alpha$) be the statement "For every interval (a, b) with rational endpoints, there is an A $\subseteq$ (a,b) such that (A, &lt;) is isomorphic to ($\alpha, \in$)."  I think that the purpose of breaking $\mathbb{Q}$ into intervals (a,b) is to make $\mathbb{Q}$ a countable set, but I don't see the significance of doing this or how it would make the proof easier.  I feel like I need to define a well-ordered set in (a,b) but I don't know how to do this since if a and b are both negative then there is no least element, so no well-ordering.  I believe that I am supposed to be using transfinite induction? But I don't know how P($\alpha$) implies P(S($\alpha$)) for S($\alpha$) successor of $\alpha$.  Any help would be greatly appreciated... thanks in advance. Author information column wise I am using authblk package and I want to achieve following output using this package. MonoTouch.Dialog: How to set limit of number of characters for EntryElement Prove $(k,n+k)=1$ iff $(k,n)=1$ (a) Prove $(k,n+k)=1$ iff $(k,n)=1$. (b) Is it true that $(k,n+k)=d$ iff $(k,n)=d$? (all variables are integers, (a,b) means gcd(a,b))  For (a), I can only get so far.  $(k,n+k)=1\ \Rightarrow\ kq_1+(n+k)q_2=k(q_1+q_2)+nq_2=1$.  Note that we don't yet have that theorem (from a different class) that says something like if $d=(a,b)$, then $d$ is the smallest (or is it biggest) number which can be made by $ak_1+bk_2$, (which I'm not quite sure how it would help, anyway). So I'm stuck. Why is it sensical for a proposition with a false antecedent to validate to true? In propositional logic, the statement "If pigs can fly, then elephants can lay eggs." validates to true because the antecedent validates to false.  In other words, given $a \rightarrow b$, if a is false, the entire statement is true. Why?  Just because the antecendent is false doesn't mean that another fact depends on it, right? Induction proof: n lines in a plane Assume that there are $n$ infinitely long straight lines lying on a plane in such a way that no two lines are parallel, and no three lines intersect at a single point. Prove that these lines divide the plane into $\frac{n^2+n+2}{2}$ regions. (Hint: Any two non-parallel straight lines on a plane must intersect at exactly one point.)  Can someone tell me where to start here? I know to prove the base where $n=0$, but don't know how to proceed.  Any help is greatly appreciated! When to use IComparable Vs. IComparer I'm trying to figure out which of these interfaces I need to implement. They both essentially do the same thing. When would I use one over the other? Global and local variables in R What do I call someone who marries or has a sexual relationship with someone much younger than themselves? Their partner is someone who is at least 18 years old.    The term paedophile is not the correct word, because it refers to minors. how to get user permissions for nfs share? Google Chrome won't install on 17.04 I had to remove Chrome to have enough space to upgrade from 16.10 to 17.04.  I downloaded the latest version from Google.  But when it opens in the Ubuntu Software Manager, and I click on "Install", nothing happens. Looking for an intuitive explanation why the row rank is equal to the column rank for a matrix Cloth collision with an object