Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

177
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!