How to detect if is_404() or is_page() or etc…? [closed]

is_404() and is_page() is simply just conditionals which just checks if a condition exists. Like is_404() simply checks if the current page is a 404 page and returns true on success and false on failure.

VERY IMPORTANT NOTICE: Conditional query tags do not work before the query is run. Before then, they always return false

You can get objects from the current page by just simply doing a var_dump on get_queried_object() like for example

 <?php
 $queried_object = get_queried_object();
 var_dump( $queried_object );
 ?>

EDIT

All of these conditionals are set in the WP_Query class, and then separately wrapped in a function in wp-includes/query.php. For instance, is_404() is just a wrapper for $wp_query->is_404();

697 /**
698  * Is the query a 404 (returns no results)?
699  *
700  * @see WP_Query::is_404()
701  * @since 1.5.0
702  * @uses $wp_query
703  *
704  * @return bool
705  */
706 function is_404() {
707         global $wp_query;
708 
709         if ( ! isset( $wp_query ) ) {
710                 _doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1' );
711                 return false;
712         }
713 
714         return $wp_query->is_404();
715 }