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

174
Vistas
How to assign variable value to an object property in javascript?

Consider this example: var v = 4; canvas.freeDrawingBrush.width = v;. I then change the value of v, and run canvas.freeDrawingBrush.width = v; again. The brush width changes as intended, however, it causes lots of bugs where some drawn paths are shifted or are partially erased. What am I doing wrong? Is it even allowed to initialize an objects property through a variable? (I am using fabric.js library).

EDIT: My original function looks like this:

switch (thickness) {
    case "small-thickness":
        v = smallThickness;
        break;
    case "medium-thickness":
        v = mediumThickness;
        break;
    case "large-thickness":
        v = largeThickness;
        break;
    default:
        v = smallThickness;
}

pencilThickness = thickness;
canvas.freeDrawingBrush.width = v;

I change the value of smallThickness, and call this block of code again.

about 4 years ago · Juan Pablo Isaza
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