THE WORLD'S LARGEST WEB DEVELOPER SITE

Node.js assert.notStrictEqual() Method

❮ Assert Module


Example

If two values are equal (both in value and type), an error is thrown and the program is terminated:

var assert = require('assert');
assert.notStrictEqual(50, 70); //OK
assert.notStrictEqual(50, "50"); //OK
assert.notStrictEqual(50, 50); /*AssertionError: 50 != 50 */
Run example »

Definition and Usage

The assert.notStrictEqual() method tests if two values are NOT equal, using the !== operator.

If the two values are equal, an assertion failure is being caused, and the program is terminated.

The !== operator tests if the values and the types are equal.

To compare the values using the != operator, use the assert.notEqual() method.


Syntax

 assert.notStrictEqual(value1, value2, message);

Parameter Values

Parameter Description
value1 Required. Specifies the first value to be compared
value2 Required. Specifies the second value to be compared
message Optional. Specifies the error message to be assigned to the AssertionError. If omitted, a default message is assigned

Technical Details

Return Value: None
Node.js Version: 0.1.21

More Examples

Example

Using the message parameter:

var assert = require('assert');
assert.notStrictEqual(50, 50, "My message goes here");
Run example »

❮ Assert Module