Find Longest, Shortest, and Random String in Array in Javascript


1. Find Longest String in Array Here I define an array list of six elements and we can see the Longest string is “Performance”. So run this script to get an answer. To Find the string we use reduce(). The reduce() the method executes a reducer function (that you provide) on each element of the array, resulting in a … Read more

How to Pass PHP Variable to JavaScript ?

Hello developer In this blog we will see how to access or use PHP variables in to Javascript. Sometime we need to just pass a PHP variable to Javascript on same page. So here simply set a variable value in PHP and we will use in show a alert in Javascript. HTML code In the … Read more

Image Preview Before Upload With Simple Javascript

This post describes how to preview an image before uploading it to the server by using javascript step by step. using FileReader and jquery. There are many methods to do this task. Some of them are through Jquery and some through pure JavaScript. So let’s start. Here is the result of the code Here is … Read more