Movatterモバイル変換


[0]ホーム

URL:


MDN Web Docs

WebAssembly.Exception.prototype.is()

BaselineWidely available

Theis() prototype method of theException object can be used to test if theException matches a given tag.

The method might be used to test that a tag is correct before passing it toException.prototype.getArg() to get the passed values.It can be used on tags created in JavaScript or created in WebAssembly code and exported to JavaScript.

Note:It is not enough that the tag has an identical sequence of data types — it must have the sameidentity (be the same tag) as was used to create the exception.

Syntax

js
is(tag)

Parameters

tag

AnWebAssembly.Tag that can be checked to verify the type of the exception.

Return value

A booleantrue if the specified tag matches the exception, andfalse otherwise.

Examples

The code below shows how to useis() to verify that a tag matches anException.

js
// Create tag and use it to create an exceptionconst tag1 = new WebAssembly.Tag({ parameters: ["i32", "f64"] });const exception1 = new WebAssembly.Exception(tag1, [42, 42.3]);// Verify that "tag1" matches this exceptionconsole.log(`Tag1: ${exception1.is(tag1)}`);// Log output:// Tag1: true

We can also demonstrate that this exception will not match another tag even if the tag is created with the same parameters.

js
// Create a new tag (with same parameters) and verify it does not match the exceptionconst tag2 = new WebAssembly.Tag({ parameters: ["i32", "f64"] });console.log(`Tag2: ${exception1.is(tag2)}`);// Log output:// Tag2: false

Specifications

Specification
WebAssembly JavaScript Interface: Exception Handling
# dom-exception-is

Browser compatibility

See also

Help improve MDN

Learn how to contribute.

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp