Index: src/wp-includes/functions.wp-scripts.php
===================================================================
--- src/wp-includes/functions.wp-scripts.php	(revision 42382)
+++ src/wp-includes/functions.wp-scripts.php	(working copy)
@@ -355,3 +355,24 @@
 function wp_script_add_data( $handle, $key, $value ) {
 	return wp_scripts()->add_data( $handle, $key, $value );
 }
+
+/**
+ * Get metadata for a script.
+ *
+ * Works only if the script has already been added.
+ *
+ * Possible values for $key and $value:
+ * 'data' array Localized script data.
+ *
+ * @since 5.0.0
+ *
+ * @see WP_Dependency::get_data()
+ *
+ * @param string $handle     Name of the script.
+ * @param string $key        Name of data point for which we're retrieving a value.
+ * @return bool|string|array False when the script is not registered, or data is not
+ *                           stored in $key, string or array of data when it exists.
+ */
+function wp_script_get_data( $handle, $key ){
+	return wp_scripts()->get_data( $handle, $key );
+}
Index: tests/phpunit/tests/dependencies/scripts.php
===================================================================
--- tests/phpunit/tests/dependencies/scripts.php	(revision 42382)
+++ tests/phpunit/tests/dependencies/scripts.php	(working copy)
@@ -185,6 +185,47 @@
 	}
 
 	/**
+	 * Testing `wp_script_get_data` with data added through `wp_localize_script`.
+	 *
+	 * @ticket 40485
+	 */
+	function test_wp_script_get_data_with_localized_data() {
+		$data = array(
+			'key' => 'value',
+			'key2' => 'value',
+		);
+		$l10n = array();
+
+		wp_enqueue_script( 'test-get-data', 'example.com', array(), null );
+		wp_localize_script( 'test-get-data', 'localized_data', $data );
+
+		// Simulate preparing data for localization.
+		foreach ( (array) $data as $key => $value ) {
+			if ( ! is_scalar( $value ) )
+				continue;
+
+			$l10n[ $key ] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' );
+		}
+
+		$localized_data = 'var localized_data = ' . wp_json_encode( $data ) . ';';
+
+		$this->assertEquals( $localized_data, wp_script_get_data( 'test-get-data', 'data' ) );
+	}
+
+	/**
+	 * Testing `wp_script_get_data` for retrieving the conditional data key.
+	 *
+	 * @ticket 40485
+	 */
+	function test_wp_script_get_data_with_conditional_key() {
+		// Enqueue & add an invalid key
+		wp_enqueue_script( 'test-get-date-conditional', 'example.com', array(), null );
+		wp_script_add_data( 'test-get-date-conditional', 'conditional', 'lt IE 9' );
+
+		$this->assertEquals( 'lt IE 9', wp_script_get_data( 'test-get-date-conditional', 'conditional' ) );
+	}
+
+	/**
 	 * Testing 'wp_register_script' return boolean success/failure value.
 	 *
 	 * @ticket 31126
