Why a='abc' is not equal to a=new String('abc')
This article mainly introduces why a="abc" is not equal to a=new String("abc"). Friends who need it can refer to it. I hope it can help everyone.
Obvious
a="abc" typeof a //string b=new String("abc") typeof b // object a==b //true a===b //false
But why? I read a lot of books and asked several experts, but I was actually still confused. Record it here for future reference.
In js, distinguish between original data type and packaging type. Numbers, strings, Boolean, null, and undefined are primitive data types, while Number, String, and Boolean are packaging types. What is created through new Number is a derived object of the packaging type. So the two are not equal.
The usage process after direct assignment to the basic type is as follows:
1. Create an instance of the String type
2. Call the specified value on the instance Method
3. Destroy the instance
Example:
var a="123" a.toFixed===Number.prototype.toFixed;
There is another saying here : Boxing, unboxing
Boxing is to use this value class to construct a corresponding packaging object
var a=10 ,b="javascript" , c=true; var o_a=new Number(a); var o_b=new String(b); var o_c=new Boolean(c);
The biggest role of boxing is to handle values as objects.
Unboxing is to convert the packaging object into a value type
var a=10; var o_a=new Number(a); var b=o_a.valueOf();//这就是拆箱的过程。
Related recommendations:
ajax gets php Return parameters of the page, control assignment method
Sharing about jquery dynamic assignment id and dynamic id retrieval method
How to give js in php Array assignment
The above is the detailed content of Why a='abc' is not equal to a=new String('abc'). For more information, please follow other related articles on the PHP Chinese website!

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

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



Bootstrap Table garbled is usually because the page encoding is inconsistent with the table data encoding. To solve this problem, you need to make sure they are consistent. The specific steps include: checking page and table data encoding, setting page encoding, and verifying the encoding. If UTF-8 is used, the server should also support it. If it cannot be resolved, try using the JavaScript encoding library.

Is JavaScript available to run without HTML5? The JavaScript engine itself can run independently. Running JavaScript in a browser environment depends on HTML5 because it provides the standardized environment required to load and execute code. The APIs and features provided by HTML5 are crucial to modern JavaScript frameworks and libraries. Without HTML5 environments, many JavaScript features are difficult to implement or cannot be implemented.

The main reasons why you cannot log in to MySQL as root are permission problems, configuration file errors, password inconsistent, socket file problems, or firewall interception. The solution includes: check whether the bind-address parameter in the configuration file is configured correctly. Check whether the root user permissions have been modified or deleted and reset. Verify that the password is accurate, including case and special characters. Check socket file permission settings and paths. Check that the firewall blocks connections to the MySQL server.

It is impossible to view MongoDB password directly through Navicat because it is stored as hash values. How to retrieve lost passwords: 1. Reset passwords; 2. Check configuration files (may contain hash values); 3. Check codes (may hardcode passwords).

The kill command in MySQL sometimes fails because of the special process status and improper signal level. Methods to effectively terminate the MySQL process include: confirming the process status, using the mysqladmin command (recommended), using kill -9 with caution, checking system resources, and in-depth troubleshooting of error logs.

The key to the efficient remote search cascading selection box is: a reasonable request strategy: load data on demand, avoid loading all data at once. Data processing: The data structure returned by the backend should be standardized, and error handling and loading status prompts should be done well. Performance optimization: Consider paging, caching and code optimization to improve loading efficiency.

There is no absolutely optimal MySQL database backup and recovery solution, and it needs to be selected based on the amount of data, business importance, RTO and RPO. 1. Logical backup (mysqldump) is simple and easy to use, suitable for small databases, but slow and huge files; 2. Physical backup (xtrabackup) is fast, suitable for large databases, but is more complicated to use. The backup strategy needs to consider the backup frequency (RPO decision), backup method (data quantity and time requirement decision) and storage location (off-site storage is more secure), and regularly test the backup and recovery process to avoid backup file corruption, permission problems, insufficient storage space, network interruption and untested issues, and ensure data security.

It is impossible to view PostgreSQL passwords directly from Navicat, because Navicat stores passwords encrypted for security reasons. To confirm the password, try to connect to the database; to modify the password, please use the graphical interface of psql or Navicat; for other purposes, you need to configure connection parameters in the code to avoid hard-coded passwords. To enhance security, it is recommended to use strong passwords, periodic modifications and enable multi-factor authentication.
