" Live as if you were to die tomorrow. Learn as if you were to live forever.. "
- Mahatma Gandhi

Emulating PHP strstr Function In JavaScript

Posted on November 23rd, 2015 by MANISH KUMAR AGARWAL

PHP predefined function strstr() is quite useful but what if we require a similar function in JavaScript ? Here is a code snippet in JavaScript doing the same thing. function strstr (haystack, findme, flag) { var position = 0; position = haystack.indexOf(findme); if (position == -1) { return false; } else { if (flag) { […]