How to use where clause in Knex
Create refunds with Stripe
Load HTML with Cheerio
How to send POST request with Axios
Find intersection of array in Lodash
Powered by Official white Bloop logo with a period

Terms / Privacy / Search / Support

  • import assert from 'assert/strict';
    
    assert.strictEqual(1, 2);
    // AssertionError [ERR_ASSERTION]: Expected inputs to be strictly equal:
    //
    // 1 !== 2
    
    assert.strictEqual(1, 1);
    // OK
    
    assert.strictEqual('Hello foobar', 'Hello World!');
    // AssertionError [ERR_ASSERTION]: Expected inputs to be strictly equal:
    // + actual - expected
    //
    // + 'Hello foobar'
    // - 'Hello World!'
    //          ^
    
    const apples = 1;
    const oranges = 2;
    assert.strictEqual(apples, oranges, `apples ${apples} !== oranges ${oranges}`);
    // AssertionError [ERR_ASSERTION]: apples 1 !== oranges 2
    
    assert.strictEqual(1, '1', new TypeError('Inputs are not identical'));
    // TypeError: Inputs are not identical
    Docs
  • const assert = require('assert');
    
    // Generate an AssertionError to compare the error message later:
    const { message } = new assert.AssertionError({
      actual: 1,
      expected: 2,
      operator: 'strictEqual'
    });
    
    // Verify error output:
    try {
      assert.strictEqual(1, 2);
    } catch (err) {
      assert(err instanceof assert.AssertionError);
      assert.strictEqual(err.message, message);
      assert.strictEqual(err.name, 'AssertionError');
      assert.strictEqual(err.actual, 1);
      assert.strictEqual(err.expected, 2);
      assert.strictEqual(err.code, 'ERR_ASSERTION');
      assert.strictEqual(err.operator, 'strictEqual');
      assert.strictEqual(err.generatedMessage, true);
    }
    Docs
  • function strict1(str) {
      'use strict';
      return eval(str); // str will be treated as strict mode code
    }
    function strict2(f, str) {
      'use strict';
      return f(str); // not eval(...): str is strict if and only
                     // if it invokes strict mode
    }
    function nonstrict(str) {
      return eval(str); // str is strict if and only
                        // if it invokes strict mode
    }
    
    strict1("'Strict mode code!'");
    strict1("'use strict'; 'Strict mode code!'");
    strict2(eval, "'Non-strict code.'");
    strict2(eval, "'use strict'; 'Strict mode code!'");
    nonstrict("'Non-strict code.'");
    nonstrict("'use strict'; 'Strict mode code!'");
    
    Docs
  • Powered by Official black Bloop logo with a period
    download the IDE extension

    View other examples