Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Articles by V Jyothi
Page 3 of 6
What is the difference between parseInt(string) and Number(string) in JavaScript?
In JavaScript, parseInt() and Number() both convert strings to numbers, but they handle invalid characters differently. Understanding their behavior is crucial for proper string-to-number conversion. parseInt() Method The parseInt() method parses a string character by character and stops at the first non-digit character, returning the parsed integer portion. console.log(parseInt("765world")); console.log(parseInt("50px")); console.log(parseInt("123.45")); console.log(parseInt("abc123")); 765 50 123 NaN Number() Method Number() attempts to convert the entire string to a number. If any part of the string is invalid, it returns NaN. console.log(Number("765world")); console.log(Number("50px")); console.log(Number("123.45")); console.log(Number("123")); NaN NaN ...
Read MoreWhat is ECMAScript and how it is related to JavaScript?
ECMAScript is the standardized specification that defines the core features and syntax of JavaScript. Understanding this relationship helps clarify how JavaScript evolved and continues to develop as a programming language. What is ECMAScript? ECMAScript (ES) is the official standard maintained by Ecma International that defines the syntax, types, statements, keywords, and objects that JavaScript implementations must follow. The ECMA-262 specification defines the standard version of the core JavaScript language. History and Relationship JavaScript was originally created by Brendan Eich at Netscape in 1995. Initially called LiveScript, it was renamed to JavaScript to capitalize on Java's popularity. ...
Read MoreHow do I remove a property from a JavaScript object?
To remove a property from a JavaScript object, use the delete keyword. The delete operator removes a property from an object and returns true if the deletion was successful. Using the delete Operator The delete operator is the most common way to remove properties from JavaScript objects. Here's the basic syntax − delete objectName.propertyName; // or delete objectName['propertyName']; Example You can try to run the following code to learn how to remove a property − var cricketer = { name: "Amit", rank: 1, ...
Read MoreUsage of Operator +n and (n) to pass data in ABAP
The +n and (n) operators in ABAP are powerful tools for string manipulation and substring extraction. These operators allow you to specify string offsets and lengths to extract specific portions of character data. If my date format is in the form DDMMYYYY then Z_Period(4) equals DDMM so (4) means first four characters. If my date format is in the form DDMMYYYY then Z_Period +4 equals YYYY so +4 means after the first four characters. So if I say ...
Read MoreUsing constants in ABAP OO method
When working with constants in ABAP Object-Oriented methods, it's important to organize your code properly. Your INCLUDE should only contain definitions of constants nothing else and then the answer is straightforward. An INCLUDE in ABAP is a way to modularize code by storing reusable components like constants, type definitions, or data declarations in separate files that can be included in multiple programs or classes. Steps to Include Constants in ABAP OO Method To expose constants from an INCLUDE in your ...
Read MoreStringTokenizer class in Java
The StringTokenizer class of the java.util package allows an application to break a string into tokens.This class is a legacy class that is retained for compatibility reasons although its use is discouraged in new code.Its methods do not distinguish among identifiers, numbers, and quoted strings.This class methods do not even recognize and skip comments.Exampleimport java.util.*; public class Sample { public static void main(String[] args) { // creating string tokenizer StringTokenizer st = new StringTokenizer("Come to learn"); // checking next token System.out.println("Next token is : " + st.nextToken()); } }OutputNext token is : Come
Read MoreHow to test String is null or empty?
We can verify whether the given string is empty using the isEmpty() method of the String class. This method returns true only if length() is 0.Exampleimport java.lang.*; public class StringDemo { public static void main(String[] args) { String str = "tutorialspoint"; // prints length of string System.out.println("length of string = " + str.length()); // checks if the string is empty or not System.out.println("is this string empty? = " + str.isEmpty()); } }Outputlength of string = 14 is this string empty? = false
Read MoreHow to Convert Double to String to Double in Java?
Java lang package provides a Double class which has methods to convert Double to String and vice versa. You can convert a String to a double using the parseDouble() method and double to String using the toString() methodExamplepublic class StringDouble { public static void main(String args[]){ Double data1 = 2.2; String str = Double.toString(data1); System.out.println(str); Double data2 = Double.parseDouble(str); System.out.println(data2); } }Output2.2 2.2
Read MorePrime number program in Java.
Following is the required program.Examplepublic class Tester { public static void main(String args[]) { int i, m = 0, flag = 0; int n = 41;// it is the number to be checked m = n / 2; if (n == 0 || n == 1) { System.out.println(n + " not a prime number"); } else { for (i = 2; i
Read MoreHow to convert Java Array to Iterable?
To make an array iterable either you need to convert it to a stream or as a list using the asList() or stream() methods respectively. Then you can get an iterator for these objects using the iterator() method.Exampleimport java.util.Arrays; import java.util.Iterator; public class ArrayToIterable { public static void main(String args[]){ Integer[] myArray = {897, 56, 78, 90, 12, 123, 75}; Iterator iterator = Arrays.stream(myArray).iterator(); while(iterator.hasNext()) { System.out.println(iterator.next()); } } }Output897 56 78 90 12 123 75As mentioned above, you can also convert an ...
Read More