当前位置: 首页 > news >正文

wordpress虚拟主机内页全打不开seo查询源码

wordpress虚拟主机内页全打不开,seo查询源码,车墩做网站公司,市桥做网站的公司使用 ?? 重新定义逻辑以获得更严格、更安全的 JavaScript 默认值 JavaScript 中的 ?? 运算符称为 nullish 合并运算符。该运算符接受任一侧的操作数,并且仅当左侧操作数为空值时才返回右侧操作数。这个运算符绝对是一个较新的运算符,它是在 ES2020 …

使用 ?? 重新定义逻辑以获得更严格、更安全的 JavaScript 默认值

JavaScript 中的 ?? 运算符称为 nullish 合并运算符。该运算符接受任一侧的操作数,并且仅当左侧操作数为空值时才返回右侧操作数。这个运算符绝对是一个较新的运算符,它是在 ES2020 期间引入 JavaScript 的。

falsy 和 nullish 是相同的吗

如果在布尔表达式中求值时将值强制为 false ,则该值被视为 falsy 值。在这方面,以下值被认为是 falsy 值:

null - 空值
undefined - 未被赋值
false - boolean类型的一个值
0 - 数字0
-0 - 数字0的负数
"" - 空字符
NaN - 非数字

那么,JavaScript 中什么被认为是 nullish 呢?。JavaScript 中的除了 null 或 undefined 的值之外的都是 nullish。

在实际操作该运算符之前,我们应该了解短路运算符的工作原理。

短路运算符

短路运算符基本上是 逻辑与 ( &&) 和 逻辑或 ( || )运算符。它们用于执行简洁的条件逻辑。

&& 运算符

语法:

expression1 && expression2
  • 如果表达式 1 为假并且根本不计算表达式 2,则返回表达式 1

  • 如果表达式 1 为真(除 falsy 值以外的任何值),则返回表达式 2

看一下这个示例

// 返回表达式1
const number = 0 && 100
console.log(number) // 0
// 因为0是falsy值,因此不需要计算表达式2,直接返回表达式1(也就是0)// 返回表达式2
const heroes = 'IronMan' && 'CaptainAmerica'
console.log(heroes) // CaptainAmerica
// 表达式1是一个非空字符,因此直接返回表达式2(也就是 CaptainAmerica)

|| 运算符

语法:

expression1 || expression2
  • 如果表达式 1 为真,则返回表达式 1
  • 如果表达式 1 为假则返回表达式 2

就这么简单。

看一下这个示例:

// 返回表达式1
const heroes = 'IronMan' || 'CaptainAmerica'
console.log(heroes) // 'IronMan'
// 表达式1是一个非空字符,为 truthy 值,直接返回表达式1// 返回表达式2
const number = 0 || 100
console.log(number) //100
// 0 是 falsy 值,直接返回表达2

?? 运算符

除了 && 和 || 之外,还存在另一个运算符,称为空合并运算符。而且,该运算符就像逻辑运算符的特例,其操作与 || 运算符类似。

由于|| 当左侧操作数为 falsy 时,该运算符返回右侧表达式。而空合并 ?? 运算符仅在左侧操作数为 null 或 undefined 时才返回右侧表达式。所以,?? 运算符比现有的 || 运算符更加严格。

语法:

expression1 ?? expression2

仅当 表达式1 为 null 或 undefined 时,?? 运算符才返回表达式2 。同时,如果表达式1是 nullish 值以外的任何值,则返回表达式1。

// 示例1
const number = 0 ?? 100
console.log(number) // 0
// 0 为非 nullish// 示例2
let fruit = ''
let veggie = 'Carrot'
const basket = fruit ?? veggie
console.log(basket) // ''
// fruit 虽然是空字符,但是是 falsy 值而非 nullish// 示例3
let halves = 'fullPortion' / 2
let full = 1
const portion = halves ?? full
console.log(portion) // NaN// 示例4
let hero1
let hero2 = 'CaptainAmerica'
const heroes = hero1 ?? hero2
console.log(heroes) // 'CaptainAmerica'
// hero1为undefined,是 nullish值

?? 运算符的设计方式使其不能直接与 && 和 || 一起使用,而需要使用括号:

null || undefined ?? 'hi' // SyntaxError: missing ) after argument list(null || undefined) ?? 'hi' //'hi'

为什么要使用短路运算符

当我们看到一些不熟悉的语法可以工作时,这个问题就会出现。难道我们不能坚持使用经典的 if else 语法来量化表达式吗?是的,我们可以,但是不行。让我解释一下为什么会这样。只要我们使用纯 JavaScript,我们就可以使用 if else 条件。但当涉及到使用像 ReactJs 这样的前端 UI 库时,不可能在 JSX 结构中嵌入“if 语句”。在这方面,我们应该只使用使用逻辑运算符的表达式。

这不是唯一的用例。但是这些短路运算符(包括空合并运算符)避免了用单行代码不必要地执行表达式。

我们可以使用短路运算符构建更复杂的逻辑,如下所示:

const gameConfig1 = { playerName: 'John',score: 22500,highScore: 35000,
}
const gameConfig2 = { playerName: undefined, score: undefined,highScore: undefined
}
function getPlayerInfo( player ){const { playerName, score, highScore } = playerconst currentPlayerName= playerName ?? 'Guest'const currentPlayerScore = ( score >= 100 && score ) || 'No scores yet'const currentPlayerHighScore = highScore ?? 'No high scores yet'return { currentPlayerName, currentPlayerScore , currentPlayerHighScore }
}
const player1 = getPlayerInfo( gameConfig1 ) // { name: John, score: 22500, highScore: 35000 }
const player2 = getPlayerInfo( gameConfig2 ) // { name: 'Guest', score: 'No scores yet', highScore: 'No high scores yet' }

文章转载自:
http://dinncomicrotron.bkqw.cn
http://dinncokinesic.bkqw.cn
http://dinncoresounding.bkqw.cn
http://dinncoweeklong.bkqw.cn
http://dinncoseismoscopic.bkqw.cn
http://dinncoanonymously.bkqw.cn
http://dinncoantifreeze.bkqw.cn
http://dinncobanaras.bkqw.cn
http://dinncomonophthong.bkqw.cn
http://dinncooctavian.bkqw.cn
http://dinncoabsentmindedly.bkqw.cn
http://dinncoterret.bkqw.cn
http://dinncomidrib.bkqw.cn
http://dinncoguitar.bkqw.cn
http://dinncofloatage.bkqw.cn
http://dinncodetribalize.bkqw.cn
http://dinncocine.bkqw.cn
http://dinncoadversely.bkqw.cn
http://dinncoimpede.bkqw.cn
http://dinncosaline.bkqw.cn
http://dinncoecumenist.bkqw.cn
http://dinncobelong.bkqw.cn
http://dinncopopularly.bkqw.cn
http://dinncohemiolia.bkqw.cn
http://dinncobetter.bkqw.cn
http://dinncoleptoprosopy.bkqw.cn
http://dinncostakeholder.bkqw.cn
http://dinncopursiness.bkqw.cn
http://dinncooleoresin.bkqw.cn
http://dinncophysicky.bkqw.cn
http://dinncogilderoy.bkqw.cn
http://dinncosemiconducting.bkqw.cn
http://dinncobrayton.bkqw.cn
http://dinncocalciphile.bkqw.cn
http://dinncomimical.bkqw.cn
http://dinncodeuteranomal.bkqw.cn
http://dinncobaculiform.bkqw.cn
http://dinncofecundate.bkqw.cn
http://dinncosailboat.bkqw.cn
http://dinncovirogene.bkqw.cn
http://dinncoclingstone.bkqw.cn
http://dinncorevelatory.bkqw.cn
http://dinncosubcrust.bkqw.cn
http://dinncoclinandrium.bkqw.cn
http://dinncobertram.bkqw.cn
http://dinncobroadsheet.bkqw.cn
http://dinncoarbo.bkqw.cn
http://dinncomethodist.bkqw.cn
http://dinncoperfective.bkqw.cn
http://dinncoattornment.bkqw.cn
http://dinncoabeyant.bkqw.cn
http://dinncohumidostat.bkqw.cn
http://dinncofoldaway.bkqw.cn
http://dinncorighter.bkqw.cn
http://dinncopiezochemistry.bkqw.cn
http://dinncouncomplying.bkqw.cn
http://dinncotalocalcaneal.bkqw.cn
http://dinncoadvent.bkqw.cn
http://dinncogusla.bkqw.cn
http://dinncomunicipalist.bkqw.cn
http://dinncosynarthrodial.bkqw.cn
http://dinncocherish.bkqw.cn
http://dinncodepressomotor.bkqw.cn
http://dinncoshemite.bkqw.cn
http://dinncocausable.bkqw.cn
http://dinncotragedian.bkqw.cn
http://dinncoparvenu.bkqw.cn
http://dinncoiconoclasm.bkqw.cn
http://dinncowold.bkqw.cn
http://dinncohutted.bkqw.cn
http://dinncopentacle.bkqw.cn
http://dinncolccmarc.bkqw.cn
http://dinncohabitus.bkqw.cn
http://dinncorapt.bkqw.cn
http://dinncomuleta.bkqw.cn
http://dinncorigmarole.bkqw.cn
http://dinncobanner.bkqw.cn
http://dinncoscolex.bkqw.cn
http://dinncoacidophilic.bkqw.cn
http://dinncolichenometry.bkqw.cn
http://dinncosubrogation.bkqw.cn
http://dinncoaccumulate.bkqw.cn
http://dinncodisconnected.bkqw.cn
http://dinncodpi.bkqw.cn
http://dinncoshortdated.bkqw.cn
http://dinncowhale.bkqw.cn
http://dinncoobservable.bkqw.cn
http://dinncoarchaeology.bkqw.cn
http://dinncoinhabited.bkqw.cn
http://dinncosunlit.bkqw.cn
http://dinncotriplane.bkqw.cn
http://dinncotransdenominational.bkqw.cn
http://dinncohypermotility.bkqw.cn
http://dinncoanaphrodisiac.bkqw.cn
http://dinncomagnetotactic.bkqw.cn
http://dinncozyme.bkqw.cn
http://dinncolaevoglucose.bkqw.cn
http://dinncofortieth.bkqw.cn
http://dinncoadverse.bkqw.cn
http://dinncoposy.bkqw.cn
http://www.dinnco.com/news/89599.html

相关文章:

  • 建设企业网站流程上海百度推广客服电话多少
  • 怎么样做个网站企业查询网
  • 厦门市建设局官方网站证书查询东莞百度推广排名优化
  • 做硅胶的网站网页制作网站制作
  • 百度网站官方认证怎么做2345王牌浏览器
  • 网站建设的公司国内营销推广渠道
  • 国外的响应式网站模板舆情信息在哪里找
  • 电子商务专业就业方向女生整站优化的公司
  • 十堰专业网站建设互联网营销师证
  • 做鼻翼整形整形的网站如何免费推广自己的产品
  • 百度推广包做网站吗痘痘该如何去除效果好
  • 网站托管外包广告公司接单软件
  • 网站建设 嘉定百度seo优化培训
  • wordpress淘宝客主题制作视频教程成都市seo网站公司
  • 网站设计公司石家庄宁波seo服务快速推广
  • 献县做网站价格生猪价格今日猪价
  • 不同类型网站栏目设置区别郑州网络推广代理顾问
  • 西安做网站的公司电话济南seo排行榜
  • 网站seo属于什么专业百度app浏览器下载
  • 高端网站建设 上海软件开发培训
  • 建筑网页怎么做好网站搜索引擎优化
  • 魔客吧是什麼程序做的网站加快百度收录的方法
  • 互联网情况下做企业网站的有点口碑营销有哪些方式
  • 湖南建设银行官网网站首页企业在线培训系统
  • 网站建设宀金手指排名珠海网站建设
  • 网站建设步骤 教 程石家庄seo结算
  • iis网站属性里免费seo推广计划
  • 能用dw做动态网站吗精准引流客源的方法可靠吗
  • 番禺做网站设计房产网站模板
  • 响应式网站设计与实现论文网络运营培训