Created
January 23, 2018 20:59
-
-
Save vmussak/16488cc43bb098e08f3e68b7a086ac56 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let listaQualquer = [ | |
'Item 001', | |
'Item 002', | |
'Item 003', | |
'Item 004' | |
]; | |
//Atual | |
let temCoisas = listaQualquer.length > 0 ? true : false; | |
//Como o resultado disso retorna 'true' ou 'false' e é isso que eu preciso... | |
//Nesse caso, utilizar o operador ternário não é necessário :) | |
let temCoisas = listaQualquer.length > 0; | |
//Ou melhor ainda... | |
//Lembram que o JS pode assumir o Zero como false? | |
//Então qualquer número diferente disso, é true! | |
//Se não tiver nada (zero) o temCoisas pode assumir 'false' | |
//E se tiver, vai assumir 'true' | |
let temCoisas = listaQualquer.length; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment