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

115
Views
¿Puedo referirme a una variable estática de una clase sin usar su nombre? (por herencia)

Digamos que tengo algo de código:

 class BuildingWithRecipe { static recipeType = "" findRecipe(){ doStuffWith([not this].recipeType); } } class Furnace extends BuildingWithRecipe { static recipeType = "smelting" }

Quiero poder acceder a un método estático de una clase con una palabra clave dentro de un método de instancia de esa clase, por lo que cuando extiendo BuildingWithRecipe (digamos con Furnace) simplemente puedo establecer la propiedad static RecipeType y el método findRecipe accederá Furnace.recipeType en lugar de BuildingWithRecipe.recipeType cuando se invoca en una instancia de Furnace.

es posible?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Puedes hacer eso con this.constructor :

 findRecipe(){ doStuffWith(this.constructor.recipeType); }
about 4 years ago · Juan Pablo Isaza Report
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!