Sunday, November 17, 2024
Google search engine
HomeLanguagesJavascriptJavaScript Generator constructor Property

JavaScript Generator constructor Property

JavaScript Generator constructor property is used to return the Generator constructor function for the object. The function which is returned by this property is just the reference to this function, not a Generator containing the function’s name. The JavaScript number constructor, string constructor, and generator constructor return function Number() { [native code] }, function String() { [native code] }, and GeneratorFunction() { [native code] } respectively.

Syntax:

generator.constructor

Return Value: function GeneratorFunction() { [native code] }

Below are examples of the Generator constructor Property. 

Example 1: This example shows the basic usage of the Generator constructor property in JavaScript.

Javascript




function* func() {}
console.log(func.constructor);


Output:

ƒ GeneratorFunction() { [native code] }

Example 2: This example uses the Generator constructor Property of Javascript.

Javascript




function myGeeks() {
    function* func() { }
 
    console.log(func.constructor);
}
myGeeks()


Output:

JavaScript Generator constructor Property

JavaScript Generator constructor Property

Supported Browsers:

  • Chrome
  • Edge 
  • Firefox
  • Opera
  • Safari

We have a complete list of JavaScript Generator methods, to check those please go through, the JavaScript Generator Reference article

Whether you’re preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, neveropen Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we’ve already empowered, and we’re here to do the same for you. Don’t miss out – check it out now!

RELATED ARTICLES

Most Popular

Recent Comments