src/com/google/javascript/jscomp/NodeUtil.java
/**
   * @return Whether the provided expression is known not to evaluate to 'undefined'.
   *
   * Similar to #getKnownValueType only for 'undefined'.  This is useful for simplifying
   * default value expressions.
   */
@return Whether the provided expression is known not to evaluate to 'undefined'.
Similar to #getKnownValueType only for 'undefined'.  This is useful for simplifying
default value expressions.
@return Whether the provided expression is known not to evaluate to ' undefined ' . Similar to #getKnownValueType only for ' undefined ' . This is useful for simplifying default value expressions .
static boolean isDefinedValue(Node value) {
    switch (value.getToken()) {
      case ASSIGN: 
      case CAST:
      case COMMA:
        return isDefinedValue(value.getLastChild());
      case AND:
      case OR:
        return isDefinedValue(value.getFirstChild())
            && isDefinedValue(value.getLastChild());
      case HOOK:
        return isDefinedValue(value.getSecondChild())
            && isDefinedValue(value.getLastChild());
      case CALL:
      case NEW:
      case GETELEM:
      case GETPROP:
      case TAGGED_TEMPLATELIT:
      case THIS:
      case YIELD:
      case AWAIT:
      case VOID:
        return false;
      case DELPROP:
      case INC:
      case DEC:
      case CLASS:
      case FUNCTION:
      case REGEXP:
      case EMPTY:
      case ARRAYLIT:
      case OBJECTLIT:
      case TEMPLATELIT:
      case STRING:
      case NUMBER:
      case NULL:
      case TRUE:
      case FALSE:
        return true;
      case TEMPLATELIT_STRING:
        return value.getCookedString() != null;
      case NAME:
        String name = value.getString();
        return "Infinity".equals(name) || "NaN".equals(name);
      default:
        if (isAssignmentOp(value) || isSimpleOperator(value)) {
          return true;
        }
        throw new IllegalStateException(
            "Unexpected expression node: " + value + "\n parent:" + value.getParent());
    }
  }
static boolean isDefinedValue ( Node value ) { switch ( value . getToken ( ) ) { case ASSIGN : case CAST : case COMMA : return isDefinedValue ( value . getLastChild ( ) ) ; case AND : case OR : return isDefinedValue ( value . getFirstChild ( ) ) && isDefinedValue ( value . getLastChild ( ) ) ; case HOOK : return isDefinedValue ( value . getSecondChild ( ) ) && isDefinedValue ( value . getLastChild ( ) ) ; case CALL : case NEW : case GETELEM : case GETPROP : case TAGGED_TEMPLATELIT : case THIS : case YIELD : case AWAIT : case VOID : return false ; case DELPROP : case INC : case DEC : case CLASS : case FUNCTION : case REGEXP : case EMPTY : case ARRAYLIT : case OBJECTLIT : case TEMPLATELIT : case STRING : case NUMBER : case NULL : case TRUE : case FALSE : return true ; case TEMPLATELIT_STRING : return value . getCookedString ( ) != null ; case NAME : String name = value . getString ( ) ; return "Infinity" . equals ( name ) || "NaN" . equals ( name ) ; default : if ( isAssignmentOp ( value ) || isSimpleOperator ( value ) ) { return true ; } throw new IllegalStateException ( "Unexpected expression node: " + value + "\n parent:" + value . getParent ( ) ) ; } }
@return Whether the provided expression is known not to evaluate to 'undefined'.
@return Whether the provided expression is known not to evaluate to ' undefined ' .
// Only the assigned value matters here. // Assume undefined leaks in this and call results. // We assume here that programs don't change the value of the keyword // undefined to something other than the value undefined. // Other op force a local value: //  '' + g (a  string) //  x -= g (x is now an number)