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.

Do not use "new" for side effects

See original GitHub issue

When I link the code with jshint I get this warning on this part of code:

new Sortable($(".typeslist")[0);

Removing new I get “Missing new prefix when invoking a constructor”…

Looks like there is a problem with your script, are you sure “Sortable” should be with the first letter capitalized? It is used for classes usually…

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:19

github_iconTop GitHub Comments

1reaction
RubaXacommented, Sep 19, 2014

Do this:

function makeSortable(el, options) {
  return new Sortable(el, options);
}

makeSortable(...);
0reactions
RubaXacommented, Sep 19, 2014

So I say, strange use. Good luck to you.

Read more comments on GitHub >

github_iconTop Results From Across the Web

EsLint - Suppress "Do not use 'new' for side effects"
In this case, the created object is thrown away because its reference isn't stored anywhere, and in many cases, this means that the...
Read more >
no-new - ESLint - Pluggable JavaScript Linter
This rule is aimed at maintaining consistency and convention by disallowing constructor calls using the new keyword that do not assign the resulting...
Read more >
Do not use 'new' for side effects - JSLint Error Explanations
This error is raised to highlight a a lack of convention. While the code is perfectly valid it contravenes best practice, and in...
Read more >
SPCAF | JSH318920: Do not use 'new' for side effects
This option prohibits the use of constructor functions for side-effects. Some people like to call constructor functions without assigning its result to any ......
Read more >
No-new - ESLint - W3cubDocs
This rule is aimed at maintaining consistency and convention by disallowing constructor calls using the new keyword that do not assign the resulting...
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