Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

157
Vistas
Javascript: what does brackets mean for object key? What does the Object.up() method do?

I came across with this code snippet:

const breakpoints = {
  values: {
    xs: 0,
    sm: 576,
    md: 768,
    lg: 992,
    xl: 1200,
    xxl: 1400,
  },
};

  const drawerOpenStyles = () => ({
    background: backgroundValue,
    transform: "translateX(0)",
    transition: transitions.create("transform", {
      easing: transitions.easing.sharp,
      duration: transitions.duration.shorter,
    }),

    [breakpoints.up("xl")]: {  // what does [] mean? what does .up() do? 
      boxShadow: transparentSidenav ? "none" : xxl,
      marginBottom: transparentSidenav ? 0 : "inherit",
      left: "0",
      width: sidebarWidth,
      transform: "translateX(0)",
      transition: transitions.create(["width", "background-color"], {
        easing: transitions.easing.sharp,
        duration: transitions.duration.enteringScreen,
      }),
    },
  });

On the line [breakpoints.up("xl")]: {}, I am having trouble understanding:

  1. What does [] do when it wraps an object key?

  2. What does Object.up() do in javascript?

I was able to print by console.log(drawerOpenStyles: ${JSON.stringify( drawerOpenStyles() )}); and I got this result:


{
   "background":"linear-gradient(195deg, #42424a, #191919)",
   "transform":"translateX(0)",
   "transition":"transform 200ms cubic-bezier(0.4, 0, 0.6, 1) 0ms",
   "@media (min-width:1200px)":{
      "boxShadow":" 0rem 1.25rem 1.6875rem 0rem rgba(0, 0, 0, 0.05)",
      "marginBottom":"inherit",
      "left":"0",
      "width":250,
      "transform":"translateX(0)",
      "transition":"width 225ms cubic-bezier(0.4, 0, 0.6, 1) 0ms,background-color 225ms cubic-bezier(0.4, 0, 0.6, 1) 0ms"
   }
}


How exactly does [breakpoints.up("xl")] give "@media (min-width:1200px)"?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

  • The square brackets [] allows you to put an expression in , that will be computed and used as the property name.
  • There is no Object.up() in the Standard Object API in JS. I think breakpoints.up("xl") is related to Material ui breakpoints check https://mui.com/customization/breakpoints/
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda