SoFunction
Updated on 2025-04-06

javascript new needs to be used

You also don't need to use new Array(), use [];
Don't use new Number, new String, or new Boolean.
Do not use new function to create functions
For example, you want to write
Copy the codeThe code is as follows:

frames[0].onfocus = new Function("='antiquewhite'")

You should write this
Copy the codeThe code is as follows:

frames[0].onfocus = function () { = 'antiquewhite';};,

The second way of writing can enable the compiler to see the function body as soon as possible. Make the error check out as soon as possible.
When you write
Js code
Copy the codeThe code is as follows:

myObj = new function () {
= 'core';
};

When writing this way
Js code
Copy the codeThe code is as follows:

myObj = {
type: 'core'
};