Tag: ECMASCRIPT-6
Estoy trabajando con javascript y tengo dos arreglos que, para este ejemplo, lucen así: const arr1 = [ { url: 1, ‘title’: ‘A’, ‘title2’: ‘A2’ }, { url: 2, ‘title’: ‘B’, ‘title2’: ‘B2’ }, { url: 3, ‘title’: ‘C’, ‘title2’: ‘C2’ }, { url: 4, ‘title’: ‘D’, ‘title2’: ‘D2’ }, . . . Read more
Digamos que tengo un objeto llamado foo y me gustaría realizar la siguiente operación: foo.bar.baz.qwer.asdf = 5; El problema es que bar puede no existir, pero si existe, entonces baz dentro de él puede no existir, etc. Pensé que sería capaz de hacer algo como esto: foo?.bar?.baz?.qwer?.asdf = 5 Pero . . . Read more
¿Cómo puedo hacer este if else más simple?\n if (!request) { return ‘no request’; } else { if (loading === ‘404’) { return ‘rejected’; } if (loading === ‘200’ && !array1.length) { return ‘fulfilled’; } } Si se utiliza algún operador ternario, ¿cómo puedo hacerlo?
Esto podría ser una pregunta duplicada simple pero no pude encontrar ninguna solución que resuelva mi caso a continuación. ¡Por favor ayúdeme! 🙂 Estoy buscando un método de cadena para verificar si el valor coincide con una cadena específica y devolver ese resultado. * Estoy usando create-react-app y tengo un . . . Read more
Tengo una matriz de objetos con la siguiente estructura: const timeOptions = [ { key: “all”, value: “all”, text: “All” }, { key: “month”, value: “month”, text: “Month” }, { key: “year”, value: “year”, text: “Year” } ]; Estoy creando un nuevo objeto con timeOptions siendo el valor de un . . . Read more