How do I ensure I can loop through every enqueued script and CSS?

In terms of the basics, I have learned that there are two actions to hook – wp_print_scripts and wp_print_styles which I understand are called just before they are then added to the header.

add_action( 'wp_print_scripts', 'my_list_scripts' );
function my_list_scripts() {
    global $wp_scripts;
    $enqueued_scripts = array();
    foreach( $wp_scripts->queue as $handle ) {
        // do something clever
    }

}
add_action( 'wp_print_styles', 'my_list_styles' );
function my_list_styles() {
    global $wp_styles;
    $enqueued_styles = array();
    foreach( $wp_styles->queue as $handle ) {
        // do something clever
    }
}