博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
javascript运算符_JavaScript赋值运算符
阅读量:2501 次
发布时间:2019-05-11

本文共 818 字,大约阅读时间需要 2 分钟。

javascript运算符

Use the assignment operator = to assign a value to a variable:

使用赋值运算符=为变量赋值:

const a = 2let b = 2var c = 2

This operator has several shortcuts for all the arithmetic operators which let you assign to the first operand the result of the operations with the second operand.

该运算符为所有算术运算符提供了几种快捷方式,您可以将第二个操作数的运算结果分配给第一个操作数。

They are:

他们是:

  • +=: addition assignment

    += :附加分配

  • -=: subtraction assignment

    -= :减法分配

  • *=: multiplication assignment

    *= :乘法分配

  • /=: division assignment

    /= :部门分配

  • %=: remainder assignment

    %= :剩余分配

  • **=: exponentiation assignment

    **= :求幂分配

Examples:

例子:

let a = 0a += 5 //a === 5a -= 2 //a === 3a *= 2 //a === 6a /= 2 //a === 3a %= 2 //a === 1

To be clear, the above operations are executed one after another, so a at the end is 1, not 0

需要明确的是,上面的操作被执行的一个接一个,所以a在端部为1,而不是0

翻译自:

javascript运算符

转载地址:http://laqgb.baihongyu.com/

你可能感兴趣的文章
cocos2dx中的层CCLayer
查看>>
Windows XP硬盘安装Ubuntu 12.04双系统图文详解
查看>>
【资料】哈代&拉马努金相关,悼文,哈佛演讲,及各种杂七杂八资料整理
查看>>
Use weechat (IRC client) on OS X. MacBook Pro
查看>>
Luogu P3616 富金森林公园
查看>>
[Nowcoder] 六一儿童节(拼多多)
查看>>
centos6.7用yum安装redis解决办法及IP限制配置
查看>>
用DataReader 分页与几种传统的分页方法的比较
查看>>
看起来像是PS的照片,实际上却令人难以置信!
查看>>
随笔一则
查看>>
WEB 小案例 -- 网上书城(一)
查看>>
加入博客园八个月了
查看>>
怎样实现前端裁剪上传图片功能
查看>>
python flask 如何修改默认端口号
查看>>
Map<String,Object> map=new HashMap<String,Object>详解
查看>>
实现tap的多种方式
查看>>
UVA - 10494 If We Were a Child Again
查看>>
html5 canvas 渲染像素混合模式
查看>>
【hexo】01安装
查看>>
CI框架源码学习笔记2——Common.php
查看>>