Friday, 3 May 2013

JavaScript Basics

 JavaScript Array:

  Here i am going to Guide you on JavaScript Arrays. Array in JS is Same as in PHP and other Programming Languages.    Here is the Syntax for creating Array,


var fruitArray = new Array( "apple", "orange", "mango","banana" );
var fruitArray = new Array[ "apple", "orange", "mango","banana" ];

 In this Array,

  fruitsarray[1] is the First element,

 fruitsarray[2] is the Second element,

 fruitsarray[3] is the Third element,

 fruitsarray[4] is the Fourth element.


new Date( ):

        This will display Current Date with Time. But We Programmers won't like to display Dates with time. But we will format it with some functions and display it.       
Here is a program to Display current date As many clients wants to display in Web Pages.

Function to display Current Date:  

function displayTodaysDate()
var x = new Array("Sunday", "Monday", "Tuesday", "Wednesday",
"Thursday", "Friday", "Saturday");
var z = new Array("January","February","March","April", "May","June",
"July", "August", "September","October","November","December");

var d = new Date();
var day = d.getDay();
var month = d.getMonth();

// Assemble the string to display
var s = x[day] + ", " + d.getDate() + " " + (z[month]) + " " + (d.getFullYear());


Output:  Friday, 3 May 2013

 Just Copy it in your Page and then Call this function using the below code,

<script type="text/javascript">



Other Syntax:

                Please Use any of the below syntax below to get desired date output in javascript
new Date(milliseconds)
new Date(datestring) new Date(year,month,date[,hour,minute,second,millisecond ])


  1. Nice blog...Very useful information is providing by ur blog. Great beginning php tutorials Very clear and helpful for beginners.


  2. Thank you for this blog post it actually couldn't have come at a better time for me !!

    Hire Yii Framework Developers

  3. Hi, Great.. Tutorial is just awesome..It is really helpful for a newbie like me.. I am a regular follower of your blog. Really very informative post you shared here. Kindly keep blogging. If anyone wants to become a Front end developer learn from Javascript Online Training from India . or learn thru JavaScript Online Training from India. Nowadays JavaScript has tons of job opportunities on various vertical industry. ES6 Online Training