Substring means a portion of a string. Substring is extracted based on numeric indexes. This article will explain 3 different ways in which a substring can be retrieved from a string in javascript. Method 1: substr function Javascript substr function takes two arguments with their meanings given below. 1. Start index: Index of character from which the substring will be extracted. 2. Count: Total number of characters or length of substring. Syntax of substr function is substr(index, length) By default characters in a string start at index 0 from left to right. Below illustration explains the working of substr function in javascript. Following points shouldRead More →

Python break statement is used to terminate or stop the execution of a loop based on some condition. As soon as the loop encounters break keyword, it is terminated and the execution resumes from the first line after the loop. break use case Suppose there is a large list of names, a dictionary of student objects or a tuple of numbers and you are searching for a particular value in these collections. Now if the element you are searching is found at the second position, why should you check all the other elements. In such a scenario, break is used. break is also used toRead More →

Converting a hexadecimal string to decimal or integer format is often required in programming applications. A common requirement is to convert IP addresses in hex to their decimal form. This article will explain the conversion of a string from hex to decimal in python. Hex to decimal conversion Python library provides an int function which can be used to convert a hex value into decimal format. It accepts 2 arguments. First is the number that needs to be converted. It may be supplied as an integer or a string. Second is the base of the first argument. int returns an integer representation(or base 10 equivalent)Read More →

Python library provides an int function which is used To convert a python string to an integer. To convert a number of a given base to a decimal. Here, decimal does not mean floating numbers but a number having base 10. int function arguments int function accepts 2 arguments. First is the number, it may be supplied as an integer or a string. Second is the base(or number system) of the first argument. Syntax Based on the above explanation, syntax of int function is int(number, base) where number may be an integer or a string which can be converted to an integer. Both arguments are optional.Read More →

It is often required to check the type of a value before performing some operation. Example, it would be better to check if the value of a variable is number before adding another number to it. This article will explain different ways in which you can check if a value is a number or not. number is a generic type in javascript. It means a value may be an integer(such as 10, 56, 1099 etc.) or a decimal(such as 10.99, 54.3232 etc.), it does not tell you the specific type of the value. Method 1: Using typeof operator Javascript typeof operator is followed by aRead More →

If you have faced or are facing the below error while running your angular application, then this post is for you. Schema validation failed with the following errors: Data path “” should NOT have additional properties(es5BrowserSupport) Solution There are two ways to remove this error, choose any of the below as per the requirement. 1. Remove es5BrowserSupport option from application Find angular.json file in your project and search for es5BrowserSupport. Comment this line as shown in the image below. Restart the application using command ng serve. This approach is not recommended if you want your application to support older browsers. 2. Upgrade versions to support es5BrowserSupport IfRead More →

If you are working on an angular application, then you should have used Observable from RxJS library. It might happen that when you start using Observable, you might encounter this error. Module ‘”<path to angular app>/node_modules/rxjs/Observable”‘ has no exported member ‘Observable’. This article will guide you through the method to resolve this error. Solution Check your imports section where Observable is imported, you should see import { Observable } from ‘rxjs/Observable’; Modify the above import to import { Observable } from ‘rxjs’; Most probably the error should go away. Reason In RxJS 5, Observable was present in the package rxjs/Observable but in RxJS 6, itRead More →

toString() method is used to convert an object to its String representation. You can call this method on a String, a StringBuffer, a java.sql.Connection object or an object of your own custom class. This method is available to all the classes because it is written in java.lang.Object class, which is the super class of all classes. Default toString() method You might have noticed that if you call toString() on an object, then it prints something like Student@4aa8fd04, where Student is the name of class. This is because when you call toString() on an object, it invokes toString() method of java.lang.Object class by default, whose implementationRead More →

Reversing a string means creating a new string whose order of characters is the opposite. That is, last character is at first position, second last is at second and so on.There are many different ways in which this can be done in javascript and this article will explain 4 different methods with example. Method 1: Using for loopThis method reverses a string without using builtin reverse function and involves the following steps. Javascript program based on these steps is written below. Steps to runCopy the above code. Save it in a file with a .html or .htm extension. Right click the file and open itRead More →