import QtQuick 2.6 Item { Component.onCompleted: { function underscoreFind(obj, predicate, context) { var findIndex = function(obj, predicate, context) { for (var i = 0; i < obj.length; i++) { if (predicate(obj[i])) { return i; } } return -1; } var key = findIndex(obj, predicate, context) console.log("type of KEY " + (typeof key)) console.log("KEY IS " + key) console.log("OBJ KEY IS " + obj[key]) var keycheck = (key !== void 0 && key !== -1) if (key !== void 0 && key !== -1) { console.log("#1 EVALUATING AS TRUE") } else{ console.log("#1 EVALUATING AS FALSE") } if (keycheck) { console.log("#2 EVALUATING AS TRUE") } else{ console.log("#2 EVALUATING AS FALSE") } } underscoreFind([,,5], function(obj){return obj !== undefined }) } }