Less than ( 您所在的位置:网站首页 lessthan Less than (

Less than (

2024-02-16 14:40| 来源: 网络整理| 查看: 265

The operands are compared with multiple rounds of coercion, which can be summarized as follows:

First, objects are converted to primitives by calling its [@@toPrimitive]() (with "number" as hint), valueOf(), and toString() methods, in that order. The left operand is always coerced before the right one. Note that although [@@toPrimitive]() is called with the "number" hint (meaning there's a slight preference for the object to become a number), the return value is not converted to a number, since strings are still specially handled. If both values are strings, they are compared as strings, based on the values of the UTF-16 code units (not Unicode code points) they contain. Otherwise JavaScript attempts to convert non-numeric types to numeric values: Boolean values true and false are converted to 1 and 0 respectively. null is converted to 0. undefined is converted to NaN. Strings are converted based on the values they contain, and are converted as NaN if they do not contain numeric values. If either value is NaN, the operator returns false. Otherwise the values are compared as numeric values. BigInt and number values can be compared together.

Other operators, including >, >=, and



【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有