checking for key
Date tested:
2 years ago
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.0.0 Safari/537.36
Test name
Executions per second
js in
226453.1 Ops/sec
js property
224278.1 Ops/sec
ramda has
215666.5 Ops/sec
Benchmark definition (click to collapse):
HTML Preparation code:
<script src="https://cdnjs.cloudflare.com/ajax/libs/ramda/0.26.1/ramda.min.js"></script>
Script Preparation code:
var test = { hi: null, hello: undefined, goodbye: 1, }
Tests:
js in
if ('hi' in test) console.log('yes')
js property
if (test.hasOwnProperty('hi')) console.log('yes')
ramda has
if (R.has('hi', test)) console.log('yes')
Open this result on MeasureThat.net