


This chapter introduces the usage of JavaScript equal sign operator. Friends in need can refer to it.
The most basic use of the equal sign operator is to compare whether two operands are equal. See the following code example:
var a=2,b=2;
console.log(a==b);
If the two operands are equal, the return value is true, otherwise it returns false.
The above is the most basic usage. Let’s introduce some of its relatively special situations.
var str="5";
var num=5;
console.log(str==num);
The return value of the above code is true.
Many friends may have questions. One is a string and the other is a numeric type. How can the return value be true? Of course, this is definitely wrong in c# or java, but in js, this is not a problem and it will be done. Implicit data type conversion, string will try to be converted to number.
Let’s look at a code example:
console.log(true==1);
The above code will also return true, because true will also be converted implicitly, it will be converted to 1, and false will be converted to false.
Let’s look at another code example:
var obj={
valueOf:function(){return 10}
}
console.log(obj==10);
An object can be directly compared with a number, and the return value is true.
This is because the object will first call the valueOf() method, and if there is no such method, it will try to call the toString() method.
The difference between two equal signs and three equal signs in JavaScript:
We often see the use of three equal signs and two equal signs in JavaScript code. Let’s introduce the difference between them.
Code example:
Example 1:
console.log(0=="");
console.log(0==false);
console.log(""==false);
Example 2:
console.log(0==="");
console.log(0===false);
console.log(""===false);
Your code above demonstrates the two operators. Let’s introduce the difference between them.
Three equal signs congruent operator:
Since it is a congruence operator, the two operands must be exactly the same to be equal. The specific comparison rules are as follows:
1. If two operations are value types, then the two operands must be completely equal to be equal.
2. If it is a reference type, the two operands must point to the same object to be equal.
Two equal sign operators:
This operator is more philanthropic. If the types of the two operands are different during comparison, type conversion will be performed. The specific rules are as follows:
1. If they are value types with the same data type, then the comparison rules are the same as the equality operator.
2. If the two operand types are the same, then they may also be the same:
a: If one is null and one is undefined, then the two are the same.
b: If one is a string and the other is a numerical value, convert the string into a numerical value and then compare.
c: If any value is true, convert it to 1 and compare. If any value is false, convert it to 0 and compare.
d: If one is an object and the other is a numeric value or string, convert the object into a value of the basic type and then compare. The object is converted to the base type using its toString or valueOf method.
The above is the entire content of this article, I hope you all like it.

Detailed explanation of JavaScript string replacement method and FAQ This article will explore two ways to replace string characters in JavaScript: internal JavaScript code and internal HTML for web pages. Replace string inside JavaScript code The most direct way is to use the replace() method: str = str.replace("find","replace"); This method replaces only the first match. To replace all matches, use a regular expression and add the global flag g: str = str.replace(/fi

So here you are, ready to learn all about this thing called AJAX. But, what exactly is it? The term AJAX refers to a loose grouping of technologies that are used to create dynamic, interactive web content. The term AJAX, originally coined by Jesse J

Article discusses creating, publishing, and maintaining JavaScript libraries, focusing on planning, development, testing, documentation, and promotion strategies.

The article discusses strategies for optimizing JavaScript performance in browsers, focusing on reducing execution time and minimizing impact on page load speed.

The article discusses effective JavaScript debugging using browser developer tools, focusing on setting breakpoints, using the console, and analyzing performance.

Bring matrix movie effects to your page! This is a cool jQuery plugin based on the famous movie "The Matrix". The plugin simulates the classic green character effects in the movie, and just select a picture and the plugin will convert it into a matrix-style picture filled with numeric characters. Come and try it, it's very interesting! How it works The plugin loads the image onto the canvas and reads the pixel and color values: data = ctx.getImageData(x, y, settings.grainSize, settings.grainSize).data The plugin cleverly reads the rectangular area of the picture and uses jQuery to calculate the average color of each area. Then, use

This article will guide you to create a simple picture carousel using the jQuery library. We will use the bxSlider library, which is built on jQuery and provides many configuration options to set up the carousel. Nowadays, picture carousel has become a must-have feature on the website - one picture is better than a thousand words! After deciding to use the picture carousel, the next question is how to create it. First, you need to collect high-quality, high-resolution pictures. Next, you need to create a picture carousel using HTML and some JavaScript code. There are many libraries on the web that can help you create carousels in different ways. We will use the open source bxSlider library. The bxSlider library supports responsive design, so the carousel built with this library can be adapted to any

Data sets are extremely essential in building API models and various business processes. This is why importing and exporting CSV is an often-needed functionality.In this tutorial, you will learn how to download and import a CSV file within an Angular


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

WebStorm Mac version
Useful JavaScript development tools

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

Dreamweaver CS6
Visual web development tools

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.