promise vs typeof

Benchmark created on


Setup

let promise = Promise.resolve('123')
let str = '123'

Test runner

Ready to run.

Testing in
TestOps/sec
instanceof
let r1 = promise instanceof Promise;
let r2 = str instanceof Promise;
ready
typeof
let r3 = typeof promise !== 'string';
let r4 = typeof str !== 'string';
ready
has then
let r5 = !!promise.then;
let r6 = !!str.then;
ready
has length
let r7 = promise.length !== undefined;
let r8 = str.length !== undefined;
ready
constructor
let r9 = promise.constructor === Promise;
let r10 = str.constructor === Promise;
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.