Is there a standard function to check for null, undefined, or blank variables in JavaScript?

Is there a universal JavaScript function that checks that a variable has a value and ensures that it’s not undefined or null? I’ve got this code, but I’m not sure if it covers all cases: function isEmpty(val){ return (val === undefined || val == null || val.length <= 0) ? true : false; } 4 … Read more

Sort array of objects by string property value

I have an array of JavaScript objects: var objs = [ { first_nom: ‘Lazslo’, last_nom: ‘Jamf’ }, { first_nom: ‘Pig’, last_nom: ‘Bodine’ }, { first_nom: ‘Pirate’, last_nom: ‘Prentice’ } ]; How can I sort them by the value of last_nom in JavaScript? I know about sort(a,b), but that only seems to work on strings and … Read more