recursal/MDN huggingface dataset:
TypeError: "x" is not a constructor
===================================

 The JavaScript exception "is not a constructor" occurs when there was an attempt to use
 an object or a variable as a constructor, but that object or variable is not a
 constructor.

Message
-------
```

TypeError: x is not a constructor (V8-based & Firefox & Safari)
```

Error type
----------

`TypeError`What went wrong?
----------------

 There was an attempt to use an object or a variable as a constructor, but that object
 or variable is not a constructor. See constructor
 or the `new` operator
 for more information on what a constructor is.

 There are many global objects, like `String` or `Array`, which
 are constructable using `new`. However, some global objects are not and their
 properties and methods are static. The following JavaScript standard built-in objects
 are not a constructor: `Math`, `JSON`, `Symbol`,
 `Reflect`, `Intl`, `Atomics`.

Generator functions cannot be used as constructors either.

Examples
--------

### Invalid cases


```js
const Car = 1;
new Car();
// TypeError: Car is not a constructor

new Math();
// TypeError: Math is not a constructor

new Symbol();
// TypeError: Symbol is not a constructor

function\* f() {}
const obj = new f();
// TypeError: f is not a constructor
```

### A car constructor

 Suppose you want to create an object type for cars. You want this type of object to be
 called `Car`, and you want it to have properties for make, model, and year.
 To do this, you would write the following function:


```js
function Car(make, model, year) {
  this.make = make;
  this.model = model;
  this.year = year;
}
```


Now you can create an object called `mycar` as follows:


```js
const mycar = new Car("Eagle", "Talon TSi", 1993);
```

### In Promises

When returning an immediately-resolved or immediately-rejected Promise, you do not need to create a `new Promise(...)` and act on it. Instead, use the `Promise.resolve()` or `Promise.reject()` static methods.

This is not legal (the `Promise` constructor is not being called correctly) and will throw a `TypeError: this is not a constructor` exception:


```js
const fn = () => {
  return new Promise.resolve(true);
};
```


This is legal, but unnecessarily long:


```js
const fn = () => {
  return new Promise((resolve, reject) => {
    resolve(true);
  });
};
```


Instead, return the static method:


```js
const resolveAlways = () => {
  return Promise.resolve(true);
};

const rejectAlways = () => {
  return Promise.reject(false);
};
```

See also
--------

* constructor
* `new`
SyntaxError: label not found
============================

The JavaScript exception "label not found" occurs when a `break` or `continue` statement references a label that does not exist on any statement that contains the `break` or `continue` statement.

Message
-------
```

SyntaxError: Undefined label 'label' (V8-based)
SyntaxError: label not found (Firefox)
SyntaxError: Cannot use the undeclared label 'label'. (Safari)
```

Error type
----------

`SyntaxError`.

What went wrong?
----------------

In JavaScript, labels are very limited: you can only use them with `break` and `continue` statements, and you can only jump to them from a statement contained within the labeled statement. You cannot jump to this label from anywhere in the program.

Examples
--------

### Unsyntactic jump

You cannot use labels as if they are `goto`.


```js
start: console.log("Hello, world!");
console.log("Do it again");
break start;
```


Instead, you can only use labels to enhance the normal semantics of `break` and `continue` statements.


```js
start: {
  console.log("Hello, world!");
  if (Math.random() > 0.5) {
    break start;
  }
  console.log("Maybe I'm logged");
}
```

See also
--------

* Labeled statement
SyntaxError: await is only valid in async functions, async generators and modules
=================================================================================

The JavaScript exception "await is only valid in async functions, async generators and modules" occurs when an `await` expression is used outside of async functions or modules or other async contexts.

Message
-------
```

SyntaxError: await is only valid in async functions and the top level bodies of modules (V8-based)
SyntaxError: await is only valid in async functions, async generators and modules (Firefox)
SyntaxError: Unexpected identifier (Safari)
```

Error type
----------

`SyntaxError`.

What went wrong?
----------------

JavaScript execution is never blocking: an `await` can never block the execution of the program. Instead, it pauses the execution of the surrounding async task, while allowing other tasks to continue running. Therefore, `await` cannot be used in sync tasks, such as functions, generator functions, or top level of scripts. It is not always apparent whether the current file is a script or a module — see the Modules guide for more information.

Examples
--------

### Top-level await

You cannot use `await` at the top level of a script:


```html
<script>
 await fetch("https://example.com");
 // SyntaxError: await is only valid in async functions, async generators and modules
</script>
```


Instead, make the script a module:


```html
<script type="module">
 await fetch("https://example.com");
</script>
```

### Async callbacks

You cannot use `await` in a sync callback:


```js
urls.forEach((url) => {
  await fetch(url);
  // SyntaxError: await is only valid in async functions, async generators and modules
});
```


Instead, make the callback async. See more explanation in the Using promises guide.


```js
Promise.all(
  urls.map(async (url) => {
    await fetch(url);
  }),
);
```

See also
--------

* `await`
SyntaxError: missing } after function body
==========================================

 The JavaScript exception "missing } after function body" occurs when there is a syntax
 mistake when creating a function somewhere. Check if any closing curly braces or
 parenthesis are in the correct order.

Message
-------
```

SyntaxError: missing } after function body (Firefox)
```

Error type
----------

`SyntaxError`What went wrong?
----------------

 There is a syntax mistake when creating a function somewhere. Also check if any closing
 curly braces or parenthesis are in the correct order. Indenting or formatting the code
 a bit nicer might also help you to see through the jungle.

Examples
--------

### Forgotten closing curly bracket

Oftentimes, there is a missing curly bracket in your function code:


```js
function charge() {
  if (sunny) {
    useSolarCells();
  } else {
    promptBikeRide();
}
```


Correct would be:


```js
function charge() {
  if (sunny) {
    useSolarCells();
  } else {
    promptBikeRide();
  }
}
```


 It can be more obscure when using IIFEs or other constructs that use
 a lot of different parenthesis and curly braces, for example.


```js
(function () {
  if (Math.random() < 0.01) {
    doSomething();
  }
)();
```


 Oftentimes, indenting differently or double checking indentation helps to spot these
 errors.


```js
(function () {
  if (Math.random() < 0.01) {
    doSomething();
  }
})();
```

See also
--------

* Functions guide
RangeError: argument is not a valid code point
==============================================

 The JavaScript exception "Invalid code point" occurs when `NaN` values,
 negative Integers (-1), non-Integers (5.4), or values larger than 0x10FFFF (1114111) are
 used with `String.fromCodePoint()`.

Message
-------
```

RangeError: Invalid code point -1 (V8-based)
RangeError: -1 is not a valid code point (Firefox)
RangeError: Arguments contain a value that is out of range of code points (Safari)
```

Error type
----------

`RangeError`What went wrong?
----------------

`String.fromCodePoint()` throws this error when passed `NaN`
 values, negative Integers (-1), non-Integers (5.4), or values larger than 0x10FFFF
 (1114111).

 A code point is a value in the
 Unicode codespace; that is, the range of integers from `0` to
 `0x10FFFF`.

Examples
--------

### Invalid cases


```js
String.fromCodePoint("\_"); // RangeError
String.fromCodePoint(Infinity); // RangeError
String.fromCodePoint(-1); // RangeError
String.fromCodePoint(3.14); // RangeError
String.fromCodePoint(3e-2); // RangeError
String.fromCodePoint(NaN); // RangeError
```

### Valid cases


```js
String.fromCodePoint(42); // "\*"
String.fromCodePoint(65, 90); // "AZ"
String.fromCodePoint(0x404); // 'Є' (U+0404)
String.fromCodePoint(0x2f804); // '你' (U+2F804)
String.fromCodePoint(194564); // '你'
String.fromCodePoint(0x1d306, 0x61, 0x1d307); // '𝌆a𝌇'
```

See also
--------

* `String.fromCodePoint()`
RangeError: invalid array length
================================

The JavaScript exception "Invalid array length" occurs when specifying an array length that is either negative, a floating number or exceeds the maximum supported by the platform (i.e. when creating an `Array` or `ArrayBuffer`, or when setting the `length` property).

 The maximum allowed array length depends on the platform, browser and browser version.
 For `Array` the maximum length is 232-1.
 For `ArrayBuffer` the maximum is 231-1 (2GiB-1) on 32-bit systems.
 From Firefox version 89 the maximum value of `ArrayBuffer` is 233 (8GiB) on 64-bit systems.

**Note:** `Array` and `ArrayBuffer` are independent data structures (the implementation of one does not affect the other).

Message
-------
```

RangeError: invalid array length (V8-based & Firefox)
RangeError: Array buffer allocation failed (V8-based)
RangeError: Array size is not a small enough positive integer. (Safari)
```

Error type
----------

`RangeError`What went wrong?
----------------

An invalid array length might appear in these situations:

* Creating an `Array` or `ArrayBuffer` with a negative length, or setting a negative value for the `length` property.
* Creating an `Array` or setting the `length` property greater than 232-1.
* Creating an `ArrayBuffer` that is bigger than 231-1 (2GiB-1) on a 32-bit system, or 233 (8GiB) on a 64-bit system.
* Creating an `Array` or setting the `length` property to a floating-point number.
* Before Firefox 89: Creating an `ArrayBuffer` that is bigger than 231-1 (2GiB-1).

 If you are creating an `Array`, using the constructor, you probably want to
 use the literal notation instead, as the first argument is interpreted as the length of
 the `Array`.

 Otherwise, you might want to clamp the length before setting the length property, or
 using it as argument of the constructor.

Examples
--------

### Invalid cases


```js
new Array(Math.pow(2, 40));
new Array(-1);
new ArrayBuffer(Math.pow(2, 32)); // 32-bit system
new ArrayBuffer(-1);

const a = [];
a.length = a.length - 1; // set the length property to -1

const b = new Array(Math.pow(2, 32) - 1);
b.length = b.length + 1; // set the length property to 2^32
b.length = 2.5; // set the length property to a floating-point number

const c = new Array(2.5); // pass a floating-point number
```

### Valid cases


```js
[Math.pow(2, 40)]; // [ 1099511627776 ]
[-1]; // [ -1 ]
new ArrayBuffer(Math.pow(2, 31) - 1);
new ArrayBuffer(Math.pow(2, 33)); // 64-bit systems after Firefox 89
new ArrayBuffer(0);

const a = [];
a.length = Math.max(0, a.length - 1);

const b = new Array(Math.pow(2, 32) - 1);
b.length = Math.min(0xffffffff, b.length + 1);
// 0xffffffff is the hexadecimal notation for 2^32 - 1
// which can also be written as (-1 >>> 0)

b.length = 3;

const c = new Array(3);
```

See also
--------

* `Array`
* `length`
* `ArrayBuffer`
RangeError: x can't be converted to BigInt because it isn't an integer
======================================================================

The JavaScript exception "x can't be converted to BigInt because it isn't an integer" occurs when the `BigInt()` function is used on a number that isn't an integer.

Message
-------
```

RangeError: The number 1.5 cannot be converted to a BigInt because it is not an integer (V8-based & Firefox)
RangeError: Not an integer (Safari)
```

Error type
----------

`RangeError`.

What went wrong?
----------------

When using the `BigInt()` function to convert a number to a BigInt, the number must be an integer (such that `Number.isInteger` returns true).

Examples
--------

### Invalid cases


```js
const a = BigInt(1.5);
// RangeError: The number 1.5 cannot be converted to a BigInt because it is not an integer
const b = BigInt(NaN);
// RangeError: NaN cannot be converted to a BigInt because it is not an integer
```

### Valid cases


```js
const a = BigInt(1);
```

See also
--------

* `BigInt()` constructor
* `Number.isInteger()`
SyntaxError: continue must be inside loop
=========================================

The JavaScript exception "continue must be inside loop" occurs when a `continue` statement is not inside a loop statement.

Message
-------
```

SyntaxError: Illegal continue statement: no surrounding iteration statement (V8-based)
SyntaxError: Illegal continue statement: 'label' does not denote an iteration statement (V8-based)
SyntaxError: continue must be inside loop (Firefox)
SyntaxError: 'continue' is only valid inside a loop statement. (Safari)
SyntaxError: Cannot continue to the label 'label' as it is not targeting a loop. (Safari)
```

Error type
----------

`SyntaxError`.

What went wrong?
----------------

`continue` statements can be used to continue a loop, and using them elsewhere is a syntax error. Alternatively, you can provide a label to the `continue` statement to continue any loop with that label — however, if the label does not reference a containing statement, another error SyntaxError: label not found will be thrown, and if the label references a statement that is not a loop, a syntax error is still thrown.

Examples
--------

### Using continue in callbacks

If you want to proceed with the next iteration in a `forEach()` loop, use `return` instead, or convert it to a `for...of` loop.


```js
array.forEach((value) => {
  if (value === 5) {
    continue; // SyntaxError: continue must be inside loop
  }
  // do something with value
});
```



```js
array.forEach((value) => {
  if (value === 5) {
    return;
  }
  // do something with value
});
```



```js
for (const value of array) {
  if (value === 5) {
    continue;
  }
  // do something with value
}
```

See also
--------

* `continue`
SyntaxError: "use strict" not allowed in function with non-simple parameters
============================================================================

 The JavaScript exception "`"use strict"` not allowed in function" occurs
 when a `"use strict"` directive is used at the top of a function with
 default parameters,
 rest parameters, or
 destructuring parameters.

Message
-------
```

SyntaxError: Illegal 'use strict' directive in function with non-simple parameter list (V8-based)
SyntaxError: "use strict" not allowed in function with default parameter (Firefox)
SyntaxError: "use strict" not allowed in function with rest parameter (Firefox)
SyntaxError: "use strict" not allowed in function with destructuring parameter (Firefox)
SyntaxError: 'use strict' directive not allowed inside a function with a non-simple parameter list. (Safari)
```

Error type
----------

`SyntaxError`.

What went wrong?
----------------

 A `"use strict"` directive is written at the top of a function that has one
 of the following parameters:

* Default parameters
* Rest parameters
* Destructuring parameters

 A `"use strict"` directive is not allowed at the top of such functions per
 the ECMAScript specification.

Examples
--------

### Function statement

 In this case, the function `sum` has default parameters `a=1` and
 `b=2`:


```js
function sum(a = 1, b = 2) {
  // SyntaxError: "use strict" not allowed in function with default parameter
  "use strict";
  return a + b;
}
```


 If the function should be in strict mode, and the
 entire script or enclosing function is also okay to be in strict mode, you can move the
 `"use strict"` directive outside of the function:


```js
"use strict";
function sum(a = 1, b = 2) {
  return a + b;
}
```

### Function expression

A function expression can use yet another workaround:


```js
const sum = function sum([a, b]) {
  // SyntaxError: "use strict" not allowed in function with destructuring parameter
  "use strict";
  return a + b;
};
```


This can be converted to the following expression:


```js
const sum = (function () {
  "use strict";
  return function sum([a, b]) {
    return a + b;
  };
})();
```

### Arrow function

 If an arrow function needs to access the `this` variable, you can use the
 arrow function as the enclosing function:


```js
const callback = (...args) => {
  // SyntaxError: "use strict" not allowed in function with rest parameter
  "use strict";
  return this.run(args);
};
```


This can be converted to the following expression:


```js
const callback = (() => {
  "use strict";
  return (...args) => {
    return this.run(args);
  };
})();
```

See also
--------

* Strict mode
* function statement
* function expression
* Default parameters
* Rest parameters
* Destructuring parameters
TypeError: invalid 'instanceof' operand 'x'
===========================================

 The JavaScript exception "invalid 'instanceof' operand" occurs when the right-hand side
 operands of the `instanceof` operator
 isn't used with a constructor object, i.e. an object which has a `prototype` property and is callable.

Message
-------
```

TypeError: Right-hand side of 'instanceof' is not an object (V8-based)
TypeError: Right-hand side of 'instanceof' is not callable (V8-based)
TypeError: invalid 'instanceof' operand "x" (Firefox)
TypeError: ({}) is not a function (Firefox)
TypeError: Right hand side of instanceof is not an object (Safari)
TypeError: {} is not a function. (evaluating '"x" instanceof {}') (Safari)
```

Error type
----------

`TypeError`What went wrong?
----------------

 The `instanceof` operator expects
 the right-hand-side operands to be a constructor object,
 i.e. an object which has a `prototype` property and is callable. It can also be an object with a `Symbol.hasInstance` method.

Examples
--------

### instanceof vs. typeof


```js
"test" instanceof ""; // TypeError: invalid 'instanceof' operand ""
42 instanceof 0; // TypeError: invalid 'instanceof' operand 0

function Foo() {}
const f = Foo(); // Foo() is called and returns undefined
const x = new Foo();

x instanceof f; // TypeError: invalid 'instanceof' operand f
x instanceof x; // TypeError: x is not a function
```


 To fix these errors, you will either need to replace
 the `instanceof` operator
 with the `typeof` operator,
 or to make sure you use the function name, instead of the result of its evaluation.


```js
typeof "test" === "string"; // true
typeof 42 === "number"; // true

function Foo() {}
const f = Foo; // Do not call Foo.
const x = new Foo();

x instanceof f; // true
x instanceof Foo; // true
```

See also
--------

* `instanceof`
* `typeof`
SyntaxError: redeclaration of formal parameter "x"
==================================================

 The JavaScript exception "redeclaration of formal parameter" occurs when the same
 variable name occurs as a function parameter and is then redeclared using a
 `let` assignment in a function body again.

Message
-------
```

SyntaxError: Identifier "x" has already been declared (V8-based)
SyntaxError: redeclaration of formal parameter "x" (Firefox)
SyntaxError: Cannot declare a let variable twice: 'x'. (Safari)
```

Error type
----------

`SyntaxError`What went wrong?
----------------

 The same variable name occurs as a function parameter and is then redeclared using a
 `let` assignment in a function body again. Redeclaring the
 same variable within the same function or block scope using `let` is not
 allowed in JavaScript.

Examples
--------

### Redeclared argument

In this case, the variable "arg" redeclares the argument.


```js
function f(arg) {
  let arg = "foo";
}

// SyntaxError: redeclaration of formal parameter "arg"
```


 If you want to change the value of "arg" in the function body, you can do so, but you
 do not need to declare the same variable again. In other words: you can omit the
 `let` keyword. If you want to create a new variable, you need to rename it as
 conflicts with the function parameter already.


```js
function f(arg) {
  arg = "foo";
}

function g(arg) {
  let bar = "foo";
}
```

See also
--------

* `let`
* `const`
* `var`
* Grammar and types guide
TypeError: property "x" is non-configurable and can't be deleted
================================================================

 The JavaScript exception "property is non-configurable and can't be deleted" occurs
 when it was attempted to delete a property, but that property is non-configurable.

Message
-------
```

TypeError: Cannot delete property 'x' of #<Object> (V8-based)
TypeError: property "x" is non-configurable and can't be deleted (Firefox)
TypeError: Unable to delete property. (Safari)
```

Error type
----------

`TypeError` in strict mode only.

What went wrong?
----------------

 It was attempted to delete a property, but that property is non-configurable. The
 `configurable` attribute controls whether the property can be deleted from
 the object and whether its attributes (other than `writable`) can be changed.

 This error happens only in strict mode code. In
 non-strict code, the operation returns `false`.

Examples
--------

### Attempting to delete non-configurable properties

 Non-configurable properties are not super common, but they can be created using
 `Object.defineProperty()` or `Object.freeze()`.


```js
"use strict";
const obj = Object.freeze({ name: "Elsa", score: 157 });
delete obj.score; // TypeError
```



```js
"use strict";
const obj = {};
Object.defineProperty(obj, "foo", { value: 2, configurable: false });
delete obj.foo; // TypeError
```



```js
"use strict";
const frozenArray = Object.freeze([0, 1, 2]);
frozenArray.pop(); // TypeError
```


 There are also a few non-configurable properties built into JavaScript. Maybe you tried
 to delete a mathematical constant.


```js
"use strict";
delete Math.PI; // TypeError
```

See also
--------

* `delete`
* `Object.defineProperty()`
* `Object.freeze()`