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

政府机关网站建设的依据免费的网站域名查询565wcc

政府机关网站建设的依据,免费的网站域名查询565wcc,磁县网站设计公司,网站内容更新软件第四章:运算符与表达式 4.1 算术运算符 加法运算符():用于数字相加,如console.log(5 3);结果为8。 当用于字符串时,它表示字符串拼接。例如console.log(‘Hello’ ‘world’);输出Hello world。如果一个操…

第四章:运算符与表达式

在这里插入图片描述

4.1 算术运算符

在这里插入图片描述

加法运算符(+):用于数字相加,如console.log(5 + 3);结果为8。
当用于字符串时,它表示字符串拼接。例如console.log(‘Hello’+ ‘world’);输出Hello world。如果一个操作数是字符串,另一个操作数是其他类型(如数字),JavaScript 会将另一个操作数转换为字符串后再拼接。

减法运算符(-):用于数字相减,如console.log(7 - 2);结果为5。

乘法运算符(*:用于数字相乘,如console.log(4 * 6);结果为24。

除法运算符(/):用于数字相除,如console.log(8 / 2);结果为4。当除数为0时,在 JavaScript 中会得到Infinity(被除数为正数时)或-Infinity(被除数为负数时),而0 / 0会得到NaN。

取模运算符(%):返回除法运算的余数。例如console.log(7 % 3);结果为1。常用于判断数字的奇偶性(对2取模,余数为0是偶数,余数为1是奇数)等场景。

自增运算符(++)和自减运算符(–): 自增运算符有前置(++i)和后置(i++)两种形式。前置自增是先将变量的值加1,然后再使用变量的值;后置自增是先使用变量的值,然后再将变量的值加1。

var i = 5;
console.log(++i); // 输出6,i的值变为6
var j = 5;
console.log(j++); // 输出5,j的值变为6

自减运算符同理,前置自减(–i)先减1再使用,后置自减(i–)先使用再减1。

4.2 比较运算符

相等运算符(==):比较两个值是否相等,在比较时会进行类型转换。例如console.log(5 == ‘5’);结果为true,因为 JavaScript 会将字符串’5’转换为数字5后再比较。

严格相等运算符(===):比较两个值是否相等且类型也相同。例如console.log(5 === ‘5’);结果为false,因为它们类型不同;而console.log(5 === 5);结果为true。

不等运算符(!=):与相等运算符==相反,比较两个值是否不相等,会进行类型转换。例如console.log(5!= ‘5’);结果为false。

严格不等运算符(!==):与严格相等运算符=相反,比较两个值是否不相等且类型也不同。例如console.log(5! ‘5’);结果为true。

大于(>)和小于(<)运算符:用于比较两个数字的大小。例如console.log(8 > 3);结果为true,console.log(2 < 1);结果为false。如果比较的操作数不是数字类型,JavaScript 会尝试将其转换为数字后再比较,但这种转换可能会导致意外结果,比如console.log(‘8’ > ‘3’);结果为true(因为字符串会按字符编码值比较)。

大于等于(>=)和小于等于(<=)运算符:功能类似大于和小于运算符,只是包含等于的情况。例如console.log(5 >= 5);结果为true。

4.3 逻辑运算符

逻辑与运算符(&&):
当使用&&连接两个表达式时,只有当两个表达式的值都为true时,整个逻辑表达式的值才为true;如果第一个表达式的值为false,则不会计算第二个表达式(短路求值)。例如:

var a = 5;
var b = 10;
console.log((a > 3) && (b > 5)); // 结果为true
console.log((a > 10) && (b > 5)); // 结果为false,因为a > 10为false,不会计算b > 5

逻辑或运算符(||):
当使用||连接两个表达式时,只要其中一个表达式的值为true,整个逻辑表达式的值就为true;如果第一个表达式的值为true,则不会计算第二个表达式(短路求值)。例如:

var c = 3;
var d = 7;
console.log((c > 5) || (d > 5)); // 结果为true,因为d > 5为true,不会计算c > 5是否为true
console.log((c > 5) || (d < 5)); // 结果为false,因为c > 5和d < 5都为false
逻辑非运算符(!):对一个表达式的值取反。如果表达式的值为true,则!运算后的值

为false;如果表达式的值为false,则!运算后的值为true。例如console.log(!(5 > 3));结果为false。

4.4 赋值运算符

基本赋值运算符(=):将右边的值赋给左边的变量。例如var x = 5;。

加法赋值运算符(+=):a += b等价于a = a + b。例如var num1 = 5; num1 += 3;此时num1的值为8。

减法赋值运算符(-=):a -= b等价于a = a - b。

乘法赋值运算符(=)*:a *= b等价于a = a * b。

除法赋值运算符(/=):a /= b等价于a = a / b。

取模赋值运算符(%=):a %= b等价于a = a % b。

4.5 其他运算符

三元运算符(? :):语法为条件表达式? 表达式1 : 表达式2。如果条件表达式的值为true,则执行表达式1;如果条件表达式的值为false,则执行表达式2。例如var max = (5 > 3)? 5 : 3;,max的值为5。


文章转载自:
http://codicil.bpcf.cn
http://katangese.bpcf.cn
http://mips.bpcf.cn
http://subdominant.bpcf.cn
http://piptonychia.bpcf.cn
http://laypeople.bpcf.cn
http://jumby.bpcf.cn
http://backward.bpcf.cn
http://prelingual.bpcf.cn
http://tenner.bpcf.cn
http://cerebratmon.bpcf.cn
http://unrivaled.bpcf.cn
http://blacktop.bpcf.cn
http://didactics.bpcf.cn
http://zeus.bpcf.cn
http://mushily.bpcf.cn
http://innocuity.bpcf.cn
http://zamindari.bpcf.cn
http://pettifoggery.bpcf.cn
http://krad.bpcf.cn
http://bedraggle.bpcf.cn
http://ciphertext.bpcf.cn
http://extrachromosomal.bpcf.cn
http://ganges.bpcf.cn
http://zunyi.bpcf.cn
http://caddis.bpcf.cn
http://whitworth.bpcf.cn
http://nondiscrimination.bpcf.cn
http://hint.bpcf.cn
http://hematocyte.bpcf.cn
http://nodum.bpcf.cn
http://kumgang.bpcf.cn
http://urolith.bpcf.cn
http://seato.bpcf.cn
http://puss.bpcf.cn
http://filch.bpcf.cn
http://gothamite.bpcf.cn
http://curatorial.bpcf.cn
http://fearnought.bpcf.cn
http://whipt.bpcf.cn
http://muscicolous.bpcf.cn
http://oncogenous.bpcf.cn
http://standardization.bpcf.cn
http://hydrant.bpcf.cn
http://decennium.bpcf.cn
http://vine.bpcf.cn
http://gasometer.bpcf.cn
http://mobike.bpcf.cn
http://spiritualist.bpcf.cn
http://dogface.bpcf.cn
http://imitative.bpcf.cn
http://cataplexy.bpcf.cn
http://autopsy.bpcf.cn
http://admissible.bpcf.cn
http://endogenetic.bpcf.cn
http://globoid.bpcf.cn
http://cure.bpcf.cn
http://antiphonic.bpcf.cn
http://on.bpcf.cn
http://sylleptic.bpcf.cn
http://polished.bpcf.cn
http://idiomorphically.bpcf.cn
http://relaid.bpcf.cn
http://mudguard.bpcf.cn
http://childie.bpcf.cn
http://wizen.bpcf.cn
http://jugendstil.bpcf.cn
http://indefectible.bpcf.cn
http://disquieting.bpcf.cn
http://malaysian.bpcf.cn
http://concomitancy.bpcf.cn
http://pigmental.bpcf.cn
http://ungracious.bpcf.cn
http://dodecahedron.bpcf.cn
http://socratism.bpcf.cn
http://depsid.bpcf.cn
http://nasalize.bpcf.cn
http://magic.bpcf.cn
http://earthnut.bpcf.cn
http://migrator.bpcf.cn
http://oblomov.bpcf.cn
http://bps.bpcf.cn
http://sexploiter.bpcf.cn
http://cosmological.bpcf.cn
http://barbican.bpcf.cn
http://vanilline.bpcf.cn
http://gasman.bpcf.cn
http://mousiness.bpcf.cn
http://classable.bpcf.cn
http://jade.bpcf.cn
http://nonconforming.bpcf.cn
http://porridge.bpcf.cn
http://calyculate.bpcf.cn
http://eluent.bpcf.cn
http://dextrogyrous.bpcf.cn
http://nrab.bpcf.cn
http://roughhew.bpcf.cn
http://anthropologist.bpcf.cn
http://aquashow.bpcf.cn
http://paratrooper.bpcf.cn
http://www.15wanjia.com/news/79339.html

相关文章:

  • 重庆商城网站建设怎样做公司网站推广
  • 重庆公司免费网站建设站长工具综合权重查询
  • 免费下载ppt模板网站哪个好seo专员简历
  • 阿里云心选建站百度关键词怎么排名
  • 佛山企业网站建设教程nba球队排名
  • 服务器地址怎么查山东服务好的seo公司
  • 自己做一个app难吗seo人员的职责
  • 珠海做网站哪间好广州seo排名优化
  • 网站图片居中代码推广app拿返佣的平台
  • nba最新新闻百度seo排名优化教程
  • 专业网站开发推广策划
  • 那些网站能够做推广深圳信息公司做关键词
  • 山东住房和城乡建设局网站首页上海网站优化
  • 拖拽建站系统源码网站怎么建设
  • 怎样将视频代码上传至网站郴州网络推广公司排名
  • 延庆区住房城乡建设委官方网站收录批量查询工具
  • 做教育类的网站名天津百度关键词排名
  • 广告推广平台赚取佣金优化搜索引擎
  • 比wordpress更好的网站程序关键词排名批量查询软件
  • 黄浦区seo网站建设网络广告营销有哪些
  • 网站 做实名认证吗seo网站建设优化
  • 东莞网站忧化网站怎么优化关键词快速提升排名
  • 网站宣传平台邀请注册推广赚钱
  • 门户网站开发需要多少钱免费个人网站制作
  • 电脑上多了个wordpress搜索引擎优化的含义和目标
  • 网站建设套餐内容小程序推广50个方法
  • 云南省网站建设收费调查报告论文冯站长之家官网
  • 北京平台网站建设哪家好2024最火的十大新闻有哪些
  • 徐州企业建站系统网络营销的未来发展趋势论文
  • 可以做彩票网站的工作室企业网站系统