The substr() method returns the characters in a string beginning at the specified location through the specified number of characters. Syntax, parameters, examples of substr() in Javascript are as below.
Tag » JavaScript
JavaScript String substring() Method
substring() is one of the main string function which is mostly used in javascript. The substring() method extracts the characters from a string, between two specified indices, and returns the new sub string.
4 ways to empty an array in JavaScript
JavaScript arrays are commonly used by developers and making them empty is also used in practice. Here I am describing 4 ways to empty an array in JavaScript:
1. Use splice() method
2. Set length to zero
3. Using pop() method
4. Set array to new empty array
Getting query string values in javascript
Sometimes we get the important data through query string but question is of getting query string values in javascript or jquery because we need these values at client side. Even we can do it by using only javascript also.
Validate email address in jQuery or JavaScript
Form validation is essential part of programming. We can validate email address in jQuery or JavaScript using regular expression. In this article, both are explained. You can check the live demo as well.
Add and Remove Classes using JavaScript
Add and Remove Classes using JavaScript is quite handy. Even it’s better to use a JavaScript framework or a library for such common tasks and I have mentioned the reason behind doing so at the end of article, these JavaScript code to adding and removing classes are worth considerable.
Array in JavaScript – push() Method
Array in JavaScript push() method appends the given element or elements in the last of array. It returns the length of the new array.
Syntax is as below:
array.push(item1, item2,.....itemN);
Array in JavaScript – slice() Method
Array in JavaScript has slice() method that is used to extract a section of an array. This method returns a new array.
Syntax is as below:
array.slice( begin [,end] );
Make a HTML, CSS, JS try it yourself editor
Making a try it yourself editor is a very easy and 5 minutes task if you know the concept behind it. Here I’m telling you step by step to create a try it yourself editor like w3 schools that would be able to run your HTML, CSS and javascript code online and display the result in iframe.
Array in JavaScript – sort() Method
sort() method for Array in JavaScript is used to sort the elements in that array.