Subject: Policy Review (500k+ available) (04.28.2014)

From: Secure $700k <[email-masked]>
Date: Wed, 28 May 2014 11:39:50 -0700

Greetings Ietf-dkim-archive,

- Update policy while your healthy / http://www.cantyep.com/may/policy/update.index

You have reached a life milestone which now qualifies you for a low Term-Life Rate.

Please Confirm Which 1 of the Following You are Experiencing here -> http://www.cantyep.com/may/policy/update.index

~ Getting Married
~ Buying A Home
~ Managing A Growing Family
~ Becoming A Stay At Home Parent
~ Running Your Own Business
~ The Single Life
~ Life After The Kids Have Moved Out
~ Planning For Retirement
~ Supporting Aging Parents
~ Estate And Legacy Planning

------ 
End Policy Update
------

we hope that you enjoyed this message
If you would like to stop further correspondence -Update Notice Messages
118 K e c k s  L a n e|Ruff Dale| PA |1 5 6 7 9
or http://www.cantyep.com/kfne.k3rj

@Steve indexOf always returns a number so theres no need to use !==. If you want to save bytes, you could use indexOf('oo') which returns a truthy value if the substring is found, and a falsy value (0) if it isnt.   Mathias Bynens Jul 7 '11 at 11:00For the curious: in two's compliment systems, -1 is represented in binary as all 1 1 1111 for 32 bit). The bitwise inverse (~) of this is all zeros, or just zero, and therefore falsy. That's why the squiggle trick works, and it is pretty bad-ass if I must say so myself.   Adam Tolley Sep 14 '11 Writing code that is unreadable because it's full of tricks isn't "bad ass" so much as just "bad".   boxed Dec 23 '11 at 8:455	  	@MathiasBynens Actually not, since if it's the first letter it will return the falsy 0, even though it contains the value. Just test in any browser console: 'hello'.indexOf('h')   Seb Nilsson Feb 7 '12 at 17:56
11	  3	  	does this work o4	  	Be careful while using inde  pramodc84 Apr 5 '12 at 9:55
13	  	@pramodc84 that link refers to the Array object indexOf method not to the String object method   gion_13 Apr 26 '12 at 13:26 I've written a small function that encapsulates this kind of behaviour (see below)   ndemoreau Jun 11 '12 at 19:37I want to give a little addition to make it non-case-sensitive which is beneficial for me: var s = "foo",t = "oo";alert(s.toLowerCase().indexOf(t.toLowerCase()) != -1);   kirlisakal Oct 3 '12 at 14:09 
Applied my new-found bitwise knowledge   Xeoncross Oct 10 '12 at 19:38 @pramodc84, that's Array.prototype.indexOf(); String.prototype.indexOf() is available everywhere.   cbrandolino Nov 28 '12 at 9:29@boxed That very much depends upon why you're writing the code and what tricks you're using. Sometimes tricks like this are necessary to make code faster/more memory efficient etc. Readability isn't everything.   Luke Dec 18 '12 at 16:44Maybe in 2016, if ECMAScript 6 is widely adopted & implemented, we'll be able to do that! :P "orange juice".contains("juice")   Lucas Pottersky Jan 10 '13 at 21:34@Luke You are right. It should be noted for the js (or development) newbie that as a general practice, preferring readability/maintainability over fine tuning is probably best. In cases where tuning is necessary explanatory comments in an uncompressed version of ones code are invaluable for pointing out what's going on and why one is being 'tricky'.   jin Nov 26 '13 at 21:08Why !== ? I prefer !
 = .   Nov 29 '13 at 15:23@NicolasBarbulesco Automagically castiny values can be very dangerous if you don't know exactly what you're doing. See this post for a more thorough explanation of the difference in these two comparison operators.   DesertIvy Dec 5 '13 at 16:28@DesertIvy  In the light of this, I confirm that I prefer !=, not !==. Here, I don't want to test the types, I want to test I am confident that all of the people who look at my code will know that [["\t\n 987654321e-400"]] === 0 is false. I am much less confident that everyone who looks at my code will know that [["\t\n 987654321e-432"]] == 0 is true.   kybernetikos Dec 11 '13 at 15:48 Blindly following the "always use !==" rule is not the answer here, you can safely use != if you know that you are comparing two numbers. -1 is NOT falsey and therefore != is always appropriate in this specific instance.   Greg Dec 11 '13 at 16:35@Greg Amen! I can't stand people who don't want to understand proper JS comparison rules and
  want to blindly follow the "always use strict comparison" rule (probably from Crockford). Strict comparison can cause bugs too.   Juan Mendes Feb 11 at 18:58 The squiggle (~str.indexOf()) could be considered idiomatic by now. Writing idiomatic JavaScript is good.   dalgard Apr 25 at 14:08@JuanMendes You "can't stand" those people? That seems...extreme.   Dustin Wyatt May 8 at 17:19@DustinWyatt I don't think it's extreme, it causes unnecessary extra code just because people who don't want to understand the difference. Specially since always using === is not the always the right answer, there are cases when you do need == and you'd need a lot of extra code to make code comply. It's the nature of a dynamic language. I agree that that's a best practice in general, but I feel that it's generally OK for app-specific code. It'd be terrible for a library though.   Avi Flax Feb 17 '11 at 20:57
@zachleat, that understandable in practice. But "foobar".contains("bar") would be a really useful exception to the rule.   Feb 22 '11 at 9:50Eh, my preference would be to adapt my mental model to fit JavaScript and just use indexOf. It will make the code easier to understand for the next JavaScripter that comes along and has to read it.   zachleat Mar 4 '11 at 16:03I agree with @Zachleat. This is a cool concept, but I also think it's important to write code that will be understandable long after you're gone. ("contains" is easy to understand, but it's easy to get carried away and write your own language in JavaScript. It's great as a Computer Science exercise but horrible in a production environment).   jmort253 Apr 1 '11 at 15:42if (typeof String.prototype.contains === 'undefined') {   String.prototype.contains = function(it) { return this.indexOf(it) != -1; }; }   Pavel Hodek Jun 7 '11 at 15:24 I this it is preferrable to use this function if you are going to be using this kind of 
 indexOf's frequently. @zachleat, I would disagree that using indexOf is more readable than contains. Contains describes what is happening, where to some indexOf() != -1 may not be so transparent. But to each their own, as long as you're consistant.   smdrager Jul 11 '11 at 14:03
2	  	If you document your modifications and share them with the team then it's fine. It's simply a matter of discipline. If your team doesn't follow documentation then you'll have bigger issues.   Bernard Sep 19 '11 at 18:183	  	if (typeof String.prototype.contains === 'undefined') { String.prototype.contains = function(it) { return this.indexOf(it) != -1; }; } else { alert ("Your code may now be broken! Check the definition of String.prototype.contains."); }   Vinko Vrsalovic Jun 21 '12 at 12:57 5	 Note that a String.prototype.contains method is in the process of being standardized, making this modification an even worse idea than it was when first answered. And it is precisely these sorts of modifications, made by unthinking web developers, that are making it such a pain to ship this new method in Firefox. (It's implemented in the latest nightly builds, and I think in Aurora builds. But it's unknown when it'll make it into a release, as there has been site breakage from the additio
 n that must be laboriously resolved first.)   Jeff Walden Sep 23 '12 at 5:1@JeffWalden: I'm curious: what causes the breakage?   Dan Tao Aug 30 '13 at 22:05
The problem is the method here isn't compatible with the built-in method. Any code that assumes the built-in method semantics will be exposed (ads on the page, WordPress plugins, anything else), will get this, and will get nonsense behavior. for a list of a bunch of sites that broke because MooTools 1.2.x implemented an incompatible String.prototype.contains (presumably by only conditionally patching, if there was no existing contains method), and the browser-provided version didn't behave like elements of the page expected.   Jeff Walden Sep 3 '13 at 22:17