博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
javascript 逗号_JavaScript中逗号的奇怪用法
阅读量:2510 次
发布时间:2019-05-11

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

javascript 逗号

I recently discovered a curious yet possibly useful thing in JavaScript, related to the comma operator.

最近,我在JavaScript中发现了一个与逗号运算符有关的奇怪但可能有用的东西。

I mostly use commas to separate properties in an object, or array items.

我通常使用逗号分隔对象或数组项中的属性。

However I never gave much attention the usage of it inside an expression.

但是,我从未在表达式中使用它。

Take this:

拿着这个:

('a', 'b')

Both expressions (in this case strings) are evaluated, and this returns the last element, the expression after the last comma. In this example it returns 'b'.

这两个表达式(在本例中为字符串)均被求值,这将返回最后一个元素,即最后一个逗号之后的表达式。 在此示例中,它返回'b'

You can assign the value to a variable, like this:

您可以将值分配给变量,如下所示:

const letter = ('a', 'b')letter === 'b' //true

翻译自:

javascript 逗号

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

你可能感兴趣的文章
Mysql出现Table 'performance_schema.session_status' doesn't exist
查看>>
MySQL innert join、left join、right join等理解
查看>>
sdc时序约束
查看>>
NoC片上网络
查看>>
开源SoC整理
查看>>
【2020-3-21】Mac安装Homebrew慢,解决办法
查看>>
influxdb 命令行输出时间为 yyyy-MM-dd HH:mm:ss(年月日时分秒)的方法
查看>>
已知子网掩码,确定ip地址范围
查看>>
判断时间或者数字是否连续
查看>>
docker-daemon.json各配置详解
查看>>
Docker(一)使用阿里云容器镜像服务
查看>>
Docker(三) 构建镜像
查看>>
FFmpeg 新旧版本编码 API 的区别
查看>>
RecyclerView 源码深入解析——绘制流程、缓存机制、动画等
查看>>
Android 面试题整理总结(一)Java 基础
查看>>
Android 面试题整理总结(二)Java 集合
查看>>
学习笔记_vnpy实战培训day02
查看>>
学习笔记_vnpy实战培训day03
查看>>
VNPY- VnTrader基本使用
查看>>
VNPY - CTA策略模块策略开发
查看>>