如何在同一行中解释=和===? [英] How to interpret = and === in the same line?

查看:92
本文介绍了如何在同一行中解释=和===?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到过这段代码

render: function() {
    var boards = [];
    for (var ii = 0; ii < this.props.numBoards; ii++) {
      // We can compare to state here so we're no longer always selecting the first board.
      var isSelected = ii === this.state.selectedIndex;
      boards.push(
        <Board index={ii} selected={isSelected}  />

      );
    }

如何选择= ii === this.state.selectedIndex 执行了吗?

以下是完整代码: http://jsbin.com/dagavu/4/embed?css,js,output

推荐答案

以下代码分两步执行

isSelected = ii === this.state.selectedIndex

1. ii === this.state.selectedIndex // comparator operator
2. isSelected = (result of step 1) // assignment operator

这篇关于如何在同一行中解释=和===?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆