Category Archives: JavaScript

javascript sort

3 Demos of How to Use JavaScript Array Sort method

The sort method The sort method is used to sort array elements in JavaScript. The JS sort method takes a parameter, which is a function, that defines how to sort elements of an array. The default sorting order is ascending and alphabetic. See an example of sort method If an array contains both numbers and

javascript array slice

JavaScript Slice Array Method with 2 Examples

The slice method of JavaScript arrays The slice method is used in arrays to get selected elements of an existing array.  You may specify where to start and end to select array elements. See an example of slice method The index starts at zero. The slice method returns an array that contains those selected elements.

JavaScript subString

How to Use JavaScript substring Method with 4 Examples

The substring method The substring method is used to get the substring of a given string by specifying the start and end numbers. The starting index is the number of character in the given string that will be included to get the The starting index is the number of character in the given string that will be included to

JavaScript prompt dialog

JavaScript Prompt Dialog With Example

The prompt dialog type The prompt dialog is the way to ask a user for some input value in the form of a dialog box. A User is given the Ok and Cancel options to proceed after entering text. If Ok is pressed it will return entered value. If Cancel is pressed, the null is returned. See a prompt

JavaScript substr method

3 Demos to Easily Learn JavaScript Substr method

What is the substr method? The substr method is used to get the substring of a given string. The substr method takes two arguments; one is the starting position and the other specifies the length of the returned substring. The Javascript substr method is different to the substring method in that you can specify end index in the substring

JavaScript Slice

Easily Understand JavaScript slice method with 3 Demos

The slice method of strings in JavaScript is used to extract the substring from a given string by specifying the start and end positions. The start and end positions are index numbers that can be positive or negative values.

JavaScript Tutorial – Learn Javascript for beginners and advanced learners

The javascript is a light-weight programming language that is generally used in client side. Today’s modern browsers like Google Chrome, Firefox, IE, Safari etc. support javascript.

The Javascript is used to make static web pages (HTML) interactive. You can include Javascript (JS) code into HTML page or refer JS files to run javascript code and perform desired activities without requesting server. The client side refers to browser running web page.

javascript setInterval

JavaScript setInterval with 3 examples

In previous chapter we learnt how to use setTimeout method to execute a given function/code once with given time delay. If you need to execute a function or code repeatedly with given time delay then use setInterval method.

The setInterval method keeps on executing given function or code by given time delay until window is closed or you can use clearInterval method to stop it.

javascript setTimeout

3 Demos to Learn JavaScript setTimeout

The setTimeout method is used to “delay” in executing a given function by specifying time in milliseconds. This is quite useful in situations like redirecting to another website while notifying a user “you will be redirected to another site in 10 seconds” etc.

The setTimeout method takes two required parameters as shown in syntax below:

javascript location.href

Ways to Use window.location.href in JavaScript (4 Demos)

The href is a property of window.location object that is used to get the complete URL of existing web page. You can also use window.location.href to set the URL of current page.

You can simply use location.href as well instead window.location.href.