The substr function is used to get one substring from a string in Javascript. In this example, we will learn how to use the substr method in Javascript with examples.
ReadJoining strings is called concatenation. In any programming language, you will have to write code for joining strings. Javascript strings are immutable, i.e. we can't change the original string. If we want to modify the string, we need to create one new string using the characters of the given string. During string concatenation, one new string is created by joining all other strings.
ReadWe can easily sort an array of strings or an array of numbers in Javascript. But, how can we sort an array of objects? For example, if you have an array of student objects with name, age, and marks for each, what is the easiest way to sort these students based on their marks or name or age? In this tutorial, we will learn to sort such arrays. In real-world, this is the most commonly faced problem and Javascript provides one simple way to solve it.
ReadJavascript indexOf() method is one of the most useful method of Javascript string. This method can be used to find out if a sub-string is included in a string or not. In this tutorial, we will learn how to use indexOf method with examples.
ReadJavascript Date has a lot of setter methods to manipulate different properties of a date object. You can easily change the year, hour, minute, milliseconds etc. of the date object using these methods. In this post, we will learn different setter methods with examples.
ReadIn Javascript, the Date object is used to work with date and time. It provides a lot of different methods to create Date and to do different modification on it. It provides a set of different getter methods to get different date properties. In this post, I will show you these getter methods with examples.
ReadDate comparison is required any time you are using Date in your code. In Javascript, we can easily compare two Date objects. In this tutorial, I will show you how to compare two Date with one example.
ReadIn this tutorial, we will learn how to count the occurrence of a character in a string in Javascript. We will show you how to do this using two different ways. You can save the program in a javascript .js file and verify it by running the file using node. Or, you can create one simple HTML file and test the code.
ReadArray splice() and slice() methods look similar, but both are different and used for different use cases. These methods are most commonly used array methods. In this tutorial, we will learn both of these methods with different examples for each.
ReadJavascript provides us a lot of different methods to manipulate array elements. Almost in any development project, we use arrays. Normally, it is required to read/update or delete any intermediate element of an array. For accessing any element in an array, we can use its index. But for adding and removing the first and the last element of an array, javascript provides us a few useful methods.
Read