Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * a utility method that will walk the object for the provided properties
- * safely asserting if the final property is equal to `other`
- * @param {Object} obj
- * @param {Array} steps
- * @param {Object} other
- * @returns {boolean} true only if properties exist for object to
- * be walked and final prop is equal to `other`
- */
- function walkEquals(obj, steps, other){
- if(!obj){
- return false;
- }
- for(let i=0; i<steps.length; i++){
- const next = obj[steps[i]];
- if(!next){
- return false;
- }
- obj = next;
- }
- return obj === other;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement