Remove Characters One By One (Closure Example)

<html> <body class=”someClass”> <input type=”button” onclick=”pp()” value=”click me”> <input type=”text” id=”jj” value=”Prashant”> </body> </html> <script src=””></script> <script src=””></script> <script type=”text/javascript”> var pp=(function(){ var name=$(“#jj”).val(); var stringlength=name.length; return function(){ var newString=”; for(i=0;i<stringlength;i++){ newString=newString+name[i]; } stringlength–; $(“#jj”).val(newString); } })(); </script>

Create Date Object

<script type=”text/javascript”> function toDate(dateStr) { var parts = dateStr.split(“-“); return new Date(parts[2], parts[1] – 1, parts[0]); } var dateObj=toDate(“23-02-2017”); var dateObj2=toDate(“1-2-2017”); alert(dateObj); alert(dateObj2); </script>

Javascript Prototype

Every JavaScript object has a prototype. The prototype is also an object. All JavaScript objects inherit their properties and methods from their prototype. JavaScript Prototypes All JavaScript objects inherit the properties and methods from their prototype. Objects created using an…

Insertion Sort

insertion sort is one of the fastest algorithms for sorting very small arrays, even faster than quicksort. Performance: Worst case: O(n2) Average case: O(n2) Best case: O(n) <?php function insertionSort(array $array) { $length=count($array); for ($i=1;$i<$length;$i++) { $element=$array[$i]; //put second element…

PHP Security Attacks and Prevention

XSS Attack- Cross site scripting CSRF ATTACK Example: <?php if(isset($_POST[“pp”])){ echo $_POST[“pp”]; } ?> <form action=”” method=”post”> <textarea name=”pp”></textarea> <input type=”submit”> </form> //now paste within comment box: <body onLoad=”document.forms[0].submit()”> <form action=””> <input type=”accountnum” value=”126172612″> <input type=”amount” value=”100″> <input type=”submit”>…

Page 2 of 712345...Last »