Giter Site home page Giter Site logo

== null is not a crime about jshint HOT 8 CLOSED

jshint avatar jshint commented on July 28, 2024 3
== null is not a crime

from jshint.

Comments (8)

paulirish avatar paulirish commented on July 28, 2024

Totally agree. I think Anton just hadn't gotten around to this one before launch.

We'll get it in soon.

from jshint.

devinus avatar devinus commented on July 28, 2024

Just FYI, using obj === undefined || obj === null is actually faster in most JS engines than obj == null. But, in general I agree that obj == null is perfectly fine.

from jshint.

Raynos avatar Raynos commented on July 28, 2024

Having code which checks for both undefined & null is bad. Your code should not be using null & undefined interchangeably.

This should be re factored so split the logical meaning of a variable being null or a variable being undefined in your code.

The only use case of it is when writing libraries to be used by others, so we don't expect them to split the logical meaning of null and undefined (which no-one does but everyone should).

from jshint.

GarrettS avatar GarrettS commented on July 28, 2024

Call me a sinner; I;ve used == null is for params. I'm w/PI on this one.

from jshint.

valueof avatar valueof commented on July 28, 2024

Don't mark == null as a poor relation when boss:true (closed by 4dbf400)

from jshint.

valueof avatar valueof commented on July 28, 2024

I've added support for == null when boss:true (4dbf400). Closing the ticket but feel free to comment the changeset.

from jshint.

amigrave avatar amigrave commented on July 28, 2024

Additionally, I would allow the usage of extra parenthesis to suppress warning even if boss is not true.

Note that's in the description for the boss option at this url
http://www.jshint.com/docs/options/#boss

You can silence this error on a per-use basis by surrounding the assignment with parenthesis, such as:
for (var i = 0, person; (person = people[i]); i++) {}

IMHO should be the same for the == null

from jshint.

Flimm avatar Flimm commented on July 28, 2024

I agree with amigrave's comment, so I converted it to issue #2456 .

from jshint.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.