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

318
Views
SyntaxError: 'super' keyword unexpected here when extending superclass

I have a super class School with properties name,level, and number of students

class School{
      constructor(name,level,numberOfStudents){
        this._name = name;
        this._level = level
        this._numberOfStudents = numberOfStudents
      }
      get name(){
        return this._name;
      }
      get level(){
        return this._level
      }
      get numberOfStudents(){
        return this._numberOfStudents
      }
    }// end School() class 
    

But when I extend that to a subclass PrimarySchool...

    class PrimarySchool extends School{
      constructror(name,numberOfStudents,pickupPolicy){
        super(name,'primary',numberOfStudents)
        this._pickupPolicy = pickupPolicy
      }
      get pickupPolicy(){
        return this._pickupPolicy
      }
    }//end PrimarySchool

I get SyntaxError: 'super' keyword unexpected here. But I should be able to pass in 'primary' as the value for the parent class property level. Same with name and numberOfStudents. Even If I declare level in the sub-class constructor and don't even pass in a value, I get the same error:

class PrimarySchool extends School{
  constructror(name,level,numberOfStudents,pickupPolicy){
    super(name,level,numberOfStudents)
    this._pickupPolicy = pickupPolicy
  }
  get pickupPolicy(){
    return this._pickupPolicy
  }
}//end PrimarySchool 
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

There is a typo in the constructror in the PrimarySchool class. The correct word is constructor. Here's a working sample code:

class School{
      constructor(name,level,numberOfStudents){
        this._name = name;
        this._level = level
        this._numberOfStudents = numberOfStudents
      }
      get name(){
        return this._name;
      }
      get level(){
        return this._level
      }
      get numberOfStudents(){
        return this._numberOfStudents
      }
    }// end School() class 
    

   class PrimarySchool extends School{
      constructor(name,numberOfStudents,pickupPolicy){
        super(name,'primary',numberOfStudents)
        this._pickupPolicy = pickupPolicy
      }
      get pickupPolicy(){
        return this._pickupPolicy
      }
    }//end PrimarySchool


const school = new PrimarySchool( 'NY School', 2137, true );

console.log( school );

Do you use any IDE with syntax highlighting or a linter (e.g. ESLint)?

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!