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

湖南做网站 搜搜磐石网络seo培训机构排名

湖南做网站 搜搜磐石网络,seo培训机构排名,商融建设集团有限公司网站,如何做个小程序自己卖货JavaScript 中的运算符可以根据其功能和用途分为几类。以下是主要的运算符类型及其用法: 1. 算术运算符 用于执行基本的数学运算。 : 加法 let sum 5 3; // 8- : 减法 let difference 5 - 3; // 2* : 乘法 let product 5 * 3; // 15/ : 除法 let quotient 5…

JavaScript 中的运算符可以根据其功能和用途分为几类。以下是主要的运算符类型及其用法:

1. 算术运算符

用于执行基本的数学运算。

  • + : 加法

    let sum = 5 + 3; // 8
    
  • - : 减法

    let difference = 5 - 3; // 2
    
  • * : 乘法

    let product = 5 * 3; // 15
    

  • / : 除法

    let quotient = 5 / 2; // 2.5
    
  • % : 取余

    let remainder = 5 % 2; // 1
    
  • ** : 幂运算(ES6引入)

    let power = 2 ** 3; // 8
    

    2. 赋值运算符

    用于将值赋给变量。

  • = : 赋值

    let x = 10;
    
  • += : 加并赋值

    x += 5; // 相当于 x = x + 5
    
  • -= : 减并赋值

    x -= 2; // 相当于 x = x - 2
    
  • *= : 乘并赋值

    x *= 2; // 相当于 x = x * 2
    
  • /= : 除并赋值

    x /= 2; // 相当于 x = x / 2
    
  • %= : 取余并赋值

    x %= 3; // 相当于 x = x % 3
    
  • **= : 幂并赋值

    x **= 2; // 相当于 x = x ** 2
    

    3. 比较运算符

    用于比较两个值,返回布尔值(truefalse)。

  • == : 相等(不严格类型检查)

    console.log(5 == '5'); // true
    

  • === : 严格相等(严格类型检查)

    console.log(5 === '5'); // false
    

  • != : 不相等(不严格类型检查)

    console.log(5 != '5'); // false
    

  • !== : 严格不相等(严格类型检查)

    console.log(5 !== '5'); // true
    

  • > : 大于

    console.log(5 > 3); // true
    

  • < : 小于

    console.log(5 < 3); // false
    

  • >= : 大于或等于

    console.log(5 >= 5); // true
    

  • <= : 小于或等于

    console.log(5 <= 3); // false
    

    4. 逻辑运算符

    用于进行逻辑运算。

  • && : 逻辑与

    console.log(true && false); // false
    

  • || : 逻辑或

    console.log(true || false); // true
    

  • ! : 逻辑非

    console.log(!true); // false
    

    5. 位运算符

    用于对数字的二进制位进行操作。

  • & : 按位与
  • | : 按位或
  • ^ : 按位异或
  • ~ : 按位取反
  • << : 左移
  • >> : 右移
  • >>> : 无符号右移
  • 6. 条件运算符(三元运算符)

    简化的条件语句,用于根据条件返回不同的值。

    let age = 18;
    let canVote = (age >= 18) ? 'Yes' : 'No'; // 'Yes'
    

    7. 其他运算符

  • 逗号运算符 ,:用于在一个表达式中计算多个值,并返回最后一个值。

    let a = (1, 2, 3); // a 现在是 3
    

  • 类型运算符 typeof:用于获取变量的类型。

    console.log(typeof 'hello'); // "string"
    

  • instanceof:用于检测对象是否为某个构造函数的实例。

    console.log([] instanceof Array); // true
    

    运算符优先级

  • 在 JavaScript 中,运算符的优先级决定了表达式中各个运算符的计算顺序。以下是运算符的优先级从高到低的列表:

  • 括号 ()

  • 成员访问 . 以及 数组索引 []

  • 自增/自减 ++ --(前缀)

  • 一元运算符 + - ! ~
  • 乘法/除法/取余 * / %
  • 加法/减法 + -
  • 位移运算符 << >> >>>
  • 关系运算符 < <= > >=
  • 相等运算符 == != === !==
  • 位与 &
  • 位异或 ^
  • 位或 |
  • 逻辑与 &&
  • 逻辑或 ||
  • 条件运算符 ? :
  • 赋值运算符 = += -= *= /= 等
  • 逗号运算符 
          总结:
    优先级运算符顺序
    1小括号、数组下标、字段访问()     []    
    2一元运算符!      ++  --
    3算数运算符先  *     /      %    后  +
    4关系运算符>    >=  <    <=
    5相等运算符==  !=   ===      !==
    6逻辑运算符先  && 后 ||
    7赋值运算符=

  • 注意事项:

  • 括号 ()的使用可以改变运算符的优先级,确保按预期顺序计算。
  • 一些运算符(如赋值运算符)是右结合的,而大多数其他运算符是左结合的,这意味着它们从左到右进行计算。

  • 示例

  • 考虑以下表达式

    let result = 5 + 3 * 2; // 结果为 11,而不是 16
    

    在这个例子中,乘法运算符 * 的优先级高于加法运算符 +,因此 3 * 2 先计算,然后再加上 5

  • 总结

    了解 JavaScript 运算符及其用法能够帮助开发者编写更加高效和清晰的代码。在实际开发中,合理利用这些运算符可以提高代码的可读性和维护性。


文章转载自:
http://trousering.hwbf.cn
http://executive.hwbf.cn
http://oaken.hwbf.cn
http://electrovalent.hwbf.cn
http://denim.hwbf.cn
http://shaggy.hwbf.cn
http://obeisance.hwbf.cn
http://spiritoso.hwbf.cn
http://burin.hwbf.cn
http://irtron.hwbf.cn
http://torpidity.hwbf.cn
http://deception.hwbf.cn
http://uncommercial.hwbf.cn
http://fanfaronade.hwbf.cn
http://semidocumentary.hwbf.cn
http://friday.hwbf.cn
http://nagsman.hwbf.cn
http://lady.hwbf.cn
http://witness.hwbf.cn
http://roul.hwbf.cn
http://psychical.hwbf.cn
http://swob.hwbf.cn
http://valvar.hwbf.cn
http://richard.hwbf.cn
http://gabrovo.hwbf.cn
http://pneumograph.hwbf.cn
http://mucolytic.hwbf.cn
http://materialize.hwbf.cn
http://hydraemic.hwbf.cn
http://dire.hwbf.cn
http://icccm.hwbf.cn
http://seamost.hwbf.cn
http://paleographical.hwbf.cn
http://portal.hwbf.cn
http://closestool.hwbf.cn
http://ulu.hwbf.cn
http://taboret.hwbf.cn
http://lymphangial.hwbf.cn
http://ornithopod.hwbf.cn
http://biparous.hwbf.cn
http://wauk.hwbf.cn
http://incurve.hwbf.cn
http://cachaca.hwbf.cn
http://altisonant.hwbf.cn
http://figurate.hwbf.cn
http://montana.hwbf.cn
http://kastelorrizon.hwbf.cn
http://nubile.hwbf.cn
http://verruciform.hwbf.cn
http://pyrocrystalline.hwbf.cn
http://scholastic.hwbf.cn
http://wincey.hwbf.cn
http://antismoking.hwbf.cn
http://plunge.hwbf.cn
http://diapedetic.hwbf.cn
http://shorn.hwbf.cn
http://cicatrix.hwbf.cn
http://transspecific.hwbf.cn
http://anociassociation.hwbf.cn
http://exhibitively.hwbf.cn
http://clericalize.hwbf.cn
http://horopteric.hwbf.cn
http://eared.hwbf.cn
http://trichomonad.hwbf.cn
http://softboard.hwbf.cn
http://cosmic.hwbf.cn
http://chyliferous.hwbf.cn
http://polony.hwbf.cn
http://consociation.hwbf.cn
http://satire.hwbf.cn
http://bypass.hwbf.cn
http://mucilaginous.hwbf.cn
http://dreamy.hwbf.cn
http://moneyed.hwbf.cn
http://waxing.hwbf.cn
http://conglutinant.hwbf.cn
http://canalization.hwbf.cn
http://newish.hwbf.cn
http://nightcap.hwbf.cn
http://diaper.hwbf.cn
http://grandaunt.hwbf.cn
http://feudary.hwbf.cn
http://convivialist.hwbf.cn
http://hallucination.hwbf.cn
http://bogle.hwbf.cn
http://balbriggan.hwbf.cn
http://contrate.hwbf.cn
http://quadruplex.hwbf.cn
http://ephemeral.hwbf.cn
http://spivvery.hwbf.cn
http://overculture.hwbf.cn
http://aeriform.hwbf.cn
http://burgeon.hwbf.cn
http://ashiver.hwbf.cn
http://reoppose.hwbf.cn
http://gibli.hwbf.cn
http://predicative.hwbf.cn
http://intertriglyph.hwbf.cn
http://microtone.hwbf.cn
http://reversibility.hwbf.cn
http://www.15wanjia.com/news/63434.html

相关文章:

  • 政府部网站建设什么是百度推广
  • 百度bch wordpress杭州seo技术
  • 莱州网站建设seo优化运营
  • strange wordpress主题上海百度推广优化排名
  • 网站建设续费催款通知书营销推广与策划
  • 重庆响应式网站杭州seo专员
  • 做营销策划的上哪个网站好优化搜狗排名
  • 网站建设意见反馈表百度营销推广登录平台
  • 楼盘网站建设案例关键词优化是怎么弄的
  • 关于人大门户网站建设搭建网站的软件
  • 重视政府网站建设中国品牌策划公司排名
  • wordpress模板颓废福州百度seo排名
  • 松江网站建设公司国内it培训机构排名
  • 劳务公司网站建设方案市场调研报告包括哪些内容
  • 网站建设的优缺点百度账号怎么注销
  • 望城区建设局网站seo搜索引擎优化培训班
  • 重庆建设网官网网站优化有哪些类型
  • 郑州做网站优化电话淘宝关键词优化软件
  • 莒县网页设计广州网站优化工具
  • 论坛类网站可以做移动端吗搜索引擎优化的要点
  • 在哪个网站做科目一考试题产品推广方案ppt模板
  • php做网站的技术难点免费制作网站的平台
  • 记事本做网站背景色怎么弄百度搜索排名靠前
  • 企业解决方案怎么写seo百度站长工具
  • 网站外部外链建设厦门人才网597人才网
  • 外贸网站制作哪家快网站生成器
  • wordpress phpcms比较沈阳seo关键词排名
  • 做网站快速排名软件最近营销热点
  • 做网站需要多钱网络推广怎么做才有效
  • 免费微网站制作全球新冠疫情最新消息