In this article, we are going learn about the weekday as a number in JavaScript with appropriate examples. To get the weekday as a number, JavaScript has provided getDay() method. The getDay() is a method from Date object. The getDay() method returns a value between 0 to 6. For example, Sunday = 0, Monday =1, Tuesday =2, Wednesday = 3 and so on. To get a better understanding, let’s look into the syntax and usage of getDay() method in JavaScript. Syntax The syntax for getDay() method is − dateObject.getDay(); Where, dateObject is an object created from date. This method ... Read More
In this article, we are going to discuss about the differences between merge sort and quick sort in JavaScript with appropriate examples. Merge sort and Quick sort are used to sort the elements, but the approach is different. Both Merge sort and quick sort are based on Divide and Conquer Strategy. Merge sort It is a stable sorting algorithm. In the merge sort, it follows a recursive approach that repeatedly splits the array into half until no more division is possible i.e., the array either remains empty or has a single element. Then by comparing the two small array elements ... Read More
A number is said to be a pointer prime number, if the sum of the product value of digits and the original prime number results in the next prime number. For more clarification, we take a prime number and multiply the digits with each other and add that multiplication value with the original number. After that if we get another prime number which is next to the original prime number. Then we can say that the number is a pointer prime number. Some examples of pointer prime numbers are: 23, 61, 1123, 1231 ... etc. In this article, ... Read More
This article discusses about \d vs\ D in JavaScript regex. The \d and \D meta characters are used to match the characters of a given string. \d and \D are different from each other. \d (character) is equivalent to [0-9] that means it matches any single number. The characters that are not matched by the \d are matched by the \D. \D is equivalent to [^0-9] that means it matches any character other than number. Both \d and \D are completely inverse to each other. To match a string with a pattern, the possible methods are: string.match(pattern), string.search(pattern), pattern.exec(string), pattern.test(text). ... Read More
This article discusses about the \w vs \W in JavaScript regex. The \w and \W meta characters are used to match the characters of a given string. \w and \W are different from each other. \w (character) is equivalent to [a-zA-Z0-9_] that means it matches any single letter, number, or underscore. The characters that are not matched by the \w are matched by the \W. \W is equivalent to [^a-zA-Z0-9_] that means it matches any character other than letter, number and underscore. To match a string with a pattern, the possible methods are: string.match(pattern), string.search(pattern), pattern.exec(string), pattern.test(text). We use match ... Read More
In this article, we are going to discuss about the super keyword in JavaScript with suitable examples. The Super keyword is basically used in Object Oriented Programming. The Super keyword is used to call parameters and functions of an object’s parent. There are times a parent class and sub class can have same method names and parameter names. In those case, to avoid confusion between the parent class and sub class method names or parameter names, super keyword is used. In order to use a Super keyword, the child method must extend the parent class method. Syntax The syntax to ... Read More
In this article, the given task is to execute digits in even places in a JavaScript array with suitable examples. To execute the digits in even places in a JavaScript array, we need to get the starting index of the array and we need to loop through it by checking whether the index is at odd place or even place. Using the filter() Method: This method will create a new array filled with elements that pass a test provided by a specified function. This method doesn’t execute the function for empty elements and this method do not modify the original ... Read More
In this article we are going to learn about the first and last child node of a specific node in JavaScript along with suitable examples. To get the first and last child node of a specific node, there are existing properties called firstChild, lastChild, firstElementChild and lastElementChild. The difference between the property of firstChild and firstElementChild is that in contrast to firstElementChild, firstChild treats both text and comments contained within html elements as children. The firstChild also considers the whitespace in the text. The same is applicable for lastChild and lastElementChild. To get the first child of a list The ... Read More
In this article we are going to discuss how to remove the child node of a specific element in JavaScript with appropriate examples. To remove the child node of a specific element, there is an existing method in JavaScript called removeChild(). The removeChild() method is different from the remove() method. The remove() method helps us to remove itself. Whereas, with the help of the removeChild() method, we can remove the child node from the parent node. Now, let’s look into the syntax and usage of removeChild() property. Syntax The syntax for removeChild() method is − removeChild(childNode); Where, childNode is ... Read More
In this article, we are going to learn about the sibling of a list element in JavaScript with suitable examples. To find the sibling of a list element in JavaScript, there is an existing property called nextSibling. The nextSibling property returns the next node on the same tree level. The nextSibling returns a node object and it is a read-only property. Note − The nextSibling propery returns the next sibling node: An element node, a comment node, a text node. The whitespaces in between the elements are also considered as text nodes. Now, Let’s look into the syntax and usage ... Read More