简体   繁体   English

没有变量的“true ===”有什么作用?

[英]What does “true ===” without a variable do?

The following code is not mine.以下代码不是我的。 Created by Microsoft Azure for window.appInsights.由 Microsoft Azure 为 window.appInsights 创建。 This code works in Edge & IE, but fails in Chrome (throws "SyntaxError: expected expression, got '&&'" in the console).此代码在 Edge 和 IE 中有效,但在 Chrome 中失败(在控制台中抛出“SyntaxError: expected expression, got '&&'”)。 Firefox complains about it, but works anyway. Firefox 抱怨它,但无论如何都可以工作。

Can someone explain to me what this is doing (attempting to do)?有人可以向我解释这是在做什么(试图做)吗? I've not seen something like this before.我以前从未见过这样的事情。

if (true === && "" !== "") {

UPDATE Thank you all for your answers.更新谢谢大家的回答。 I thought it was poorly written code, but wanted to be sure it didn't contain a coding shorthand I wasn't aware of.我认为这是写得很糟糕的代码,但想确保它不包含我不知道的编码速记。 Your answers cleared that up for me !你的回答让我明白了!

It probably is a mistake.这可能是一个错误。 It shouldn't work.它不应该工作。 === is a binary operator and therefore expects 2 operands not 1. && is not an expression neither a valid identifier. ===是二元运算符,因此需要 2 个操作数而不是 1。 &&不是表达式,也不是有效标识符。

Read it in english.用英文阅读。 if true is strictly equal to or empty string is strictly not equal to empty string


i wonder what "" !== "" is trying to do since it will always evaluate to false lol我想知道"" !== ""正在尝试做什么,因为它总是会评估为假大声笑

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM