Every line of 'how to return the first value of this array' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.
332 function getFirst(array) { 333 if (!empty(array)) { 334 return array[0]; 335 } 336 return null; 337 }
Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code
37 function getFirstValue(arr) { 38 if (arr && arr.length > 0 && arr[0].value) { 39 return arr[0].value; 40 } 41 }