- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 7019 Articles for Javascript
375 Views
In this tutorial, we will learn how to get the last index of an occurrence of the specified value in a string in JavaScript. The last index of an occurrence means the last position found of the searched item in a given string. It can be a single character or a word also. To find the index of the last occurrence, we have a method in JavaScript that is the lastIndexOf() method. Using the lastIndexOf() Method This method will search the whole string and return the index of that value's last position. If it doesn’t find the item, it ... Read More
186 Views
In this tutorial, we will learn what are the methods of a boolean object in JavaScript. First, we will learn about what is a boolean object. The boolean object represents two values: ‘true’ and ‘false’. The boolean object’s default value is false if the value parameter is missing, 0, -0, null, false, NaN, undefined, or the empty string (‘’). The Boolean object value will be set to true for any other values. The boolean objects have some properties such as constructor and prototype and some methods like toString() and valueOf(). Here we will emphasize these two methods. Users can follow ... Read More
305 Views
In this tutorial, we will learn what the properties of a boolean object in JavaScript are. The Boolean object represents two values: ‘true’ or ‘false.’ If the value parameter is omitted or is 0, -0, null, false, NaN, undefined, or the empty string (‘’), the object has the value false as its default. Any other values will set the Boolean object value to true. In addition, the Boolean object has properties such as constructor and prototype and methods such as toString() and valueOf(). Users can follow the below syntax to initialize a Boolean object. Syntax const boolean_object = new Boolean(value/expression) ... Read More
3K+ Views
In this tutorial, we will learn how to initialize a boolean array in JavaScript. We can initialize a boolean array in JavaScript in three ways− Using the fill() Method Using the Array from() Method Using the for Loop Using the fill() Method We can initialize a boolean array using the fill() method. The fill() method sets the static value of all array elements from the beginning index to the end index. Syntax //initialization of boolean array with fill() method let arrayName = new Array(array_length).fill(true/false); In the above syntax, we create an array with the name "arrayName" ... Read More
21K+ Views
In this tutorial, we will learn to check if the variable is a Boolean in JavaScript. In JavaScript, if we match the two different variables with the same value and different data types using the equality operator, it returns a true value. It means if we compare a twovariable with the true value but different data types such as Boolean and string, it will generate a positive result. To overcome these problems, we need to check if the variable is of type Boolean or not before matching it with other values. Users can use the three methods below to check ... Read More
2K+ Views
To declare a Boolean in JavaScript, you need to assign true or false value.var answer = true;ExampleTo learn about the working of Boolean, let’s see the following example −Live Demo JavaScript Boolean var num1 = 10; var num2 = 20; document.write(num1 > num2);
210 Views
The Boolean object represents two values, either "true" or "false". If the value parameter is omitted or is 0, -0, null, false, NaN, undefined, or the empty string (""), the object has an initial value of false.Create a Boolean object like this −var val = new Boolean(value);ExampleYou can try to run the following code to learn how to create a Boolean object −Live Demo JavaScript toString() Method var flag = new Boolean(true); document.write( "flag.toString is : " + flag.toString() );
87 Views
In JavaScript, the Number.toExponential() method returns a string of a number representing the given number in its exponential form. This method is basically used to convert a number to its exponential form. Syntax The following syntax will show you how you can use the Number.toExponential() method to convert a number into its exponential value Number.toExponential( fractionDigits ); The fractionDigits parameter is an integer specifying the number of digits after the decimal point. Let us understand the implementation of the toExponential() method in details with the help of code examples Algorithm Step 1 − In the first step of the ... Read More
142 Views
Number.NEGATIVE_INFINITY is a special numeric value representing a value less than Number.MIN_VALUE. This value is represented as "-Infinity". It resembles infinity in its mathematical behavior. But it is different from the mathematical infinity in many ways as listed below − If the negative infinity is multiplied by NaN, the result will be NaN. When a negative infinity is multiplied by a positive infinity, the result will always be a negative infinity. If a negative infinity is multiplied by itself, then the result will always be positive infinity. Negative infinity, divided by positive infinity or by itself will return ... Read More
203 Views
The Number.MAX_VALUE property belongs to the static Number object. It represents constants for the largest possible positive numbers that JavaScript can work with.The Number.MIN_VALUE property belongs to the static Number object. It represents constants for the smallest possible positive numbers that JavaScript can work with.ExampleYou can try to run the following code to learn about the MAX and MIN value in JavaScript −Live Demo function showMinValue() { var val = Number.MIN_VALUE; alert("Value of Number.MIN_VALUE : " + val ... Read More