Javascript字符串和字符比较

时间:2017-04-21 19:45:28

标签: javascript

为什么'Mystery!' <= 'Z'等于true'the' <= 'Z'等于false但是  'Mystery!' >= 'A''the' >= 'A'等于true。这种比较如何运作?

2 个答案:

答案 0 :(得分:3)

它将UTF-16代码与字符串值进行比较。尝试使用charCodeAt方法进行相同的比较,以了解这里发生了什么

DECLARE @now DATETIME
DECLARE @90daysago DATETIME

SET @now = GETDATE()
SET @90daysago = DATEADD(day, -90, @now)

SELECT
    o.JobNo,
    o.OrderNo,
    o.PartNo,
    o.Status,
    o.JobNo,
    t.TicketDate,
    p.Status,
    p.OutSideService,
    p.PONum,
    po.DateEnt,
    po.DateMod


FROM
    RBCBEMD.dbo.OrderDet AS o       /* OrderDet = o */

INNER JOIN RBCBEMD.dbo.TimeTicketDet AS t       /* TimeTicket = t */
    ON o.JobNo = t.JobNo

INNER JOIN RBCBEMD.dbo.PODet AS p           /* PODet = p */
    ON o.JobNo = p.JobNo

INNER JOIN RBCBEMD.dbo.PO AS po         /* PO = po */
    ON p.PONum = po.PONum

WHERE 
    o.Status = 'Open' AND
    t.TicketDate <= @90daysago AND
    po.DateMod <= @90daysago
and not exists (
    select 1
    from RBCBEMD.dbo.TimeTicketDet as t2
    where t2.JobNo = o.JobNo
    and t2.TicketDate > t.TicketDate
    )

ORDER BY
    cast(t.TicketDate as DATETIME) DESC

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/charCodeAt

答案 1 :(得分:2)

小写字母前的大写字母。

M = ascii value 77
Z = 90

77 < 90

t = 116
Z = 90

116 !< 90

在此处查看更多信息:www.asciitable.com