question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Confusing wording which should be changed

See original GitHub issue

Describe the Issue

The difference between ES5 and ES6 construction is the removal of keyword function. The constructor in ES6 or function constructor in ES5 is invoked by a new keyword.

The wording of the question says

In ES5, we usually define a constructor function and use the new keyword to instantiate an object.

and then after code

The class syntax simply replaces the constructor function creation:

Affected Page

https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/es6/use-class-syntax-to-define-a-constructor-function

Your code

NA

Expected behavior

In my experience, it should be

The class syntax simply replaces the keyword function with construction.

Screenshots

Screenshot 2022-09-09 at 10 20 04

System

  • Device: [e.g. iPhone 6, Laptop]
  • OS: [e.g. iOS 14, Windows 10, Ubuntu 20.04]
  • Browser: [e.g. Chrome, Safari]
  • Version: [e.g. 22]

Additional context

No response

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:17 (16 by maintainers)

github_iconTop GitHub Comments

2reactions
jeremyltcommented, Sep 12, 2022

Something like this?


In ES5, an object can be created by defining a constructor function and using the new keyword to instantiate the object.

The ES6 class syntax replaces the ES5 constructor function with a constructor method:

class SpaceShuttle {
  constructor(targetPlanet) {
    this.targetPlanet = targetPlanet;
  }
}
const zeus = new SpaceShuttle('Jupiter');
1reaction
jeremyltcommented, Oct 6, 2022

In ES5, an object can be created by defining a constructor function and using the new keyword to instantiate the object.

In ES6, a class declaration has a constructor method that is invoked with the new keyword. If this method is not explicitly defined, then it is implicitly defined with no arguments.

// Explicit constructor
class SpaceShuttle {
  constructor(targetPlanet) {
    this.targetPlanet = targetPlanet;
  }
  takeoff() {
    console.log("To " this.targetPlanet + "!") ;
  }
}

// Implicit constructor 
class Rocket {
  launch() {
    console.log("To the moon!") ;
  }
}

const zeus = new SpaceShuttle('Jupiter');
const atlas = new Rocket();
Read more comments on GitHub >

github_iconTop Results From Across the Web

Commonly Confused Words | Effective Writing Practices Tutorial
The common mistake is to use the phrase "could care less." If you want to express the meaning of not caring about something,...
Read more >
Commonly Confused Words | University of Illinois Springfield
Commonly Confused Words. Some words look the same, while others sound the same. Knowing the difference between these similar words can be very...
Read more >
4.1 Commonly Confused Words – Writing for Success
Affect (verb ). Means to create a change. Hurricane winds affect the amount of rainfall. Effect (noun). Means an outcome or result.
Read more >
What is a misplaced modifier
Misplaced modifiers can usually be corrected by moving the modifier to a more sensible place in the sentence, generally next to the word...
Read more >
Commonly Confused Words
Words evolve with use and misuse over time, sometimes obscuring their meanings. Here are current conjugations and clarifications of some commonly confused ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found