"falsy" values confused me


(Guxima) #1

One caveat is that some “falsy” values, such as the 0 number, are still rendered by React. For example, this code will not behave as you might expect because 0 will be printed when props.messages is an empty array

i got a demo with babel
"use strict";

var array = [];
function World() {
  return React.createElement(
    "h1",
    null,
    "world"
  );
}
function hello() {
  return React.createElement(
    "div",
    null,
    array.length && React.createElement(World, null)
  );
}

array.length && React.createElement(World, null) this won’t be exec