Big News: FounderDating is joining OneVest to build the largest community for entrepreneurs. Details here
Latest Notifications
You have no recent recommendations.
Name
Title
 
MiniBio
FOLLOW
Title
 Followers
FOLLOW TOPIC

Question goes here

1,300 Followers

  • Name
    Entrepreneur
  • Name
    Entrepreneur
  • Name
    Entrepreneur
  • Name
    Entrepreneur
  • Name
    Entrepreneur
  • Name
    Entrepreneur
  • Name
    Entrepreneur
  • Name
    Entrepreneur

What does “!--” do in JavaScript?

For me right now this is a wonderful way to confuse the next person that is maintaining the code... Help please!

7 Replies

Charles Bastian
0
0
Charles Bastian Entrepreneur
Experienced Fixer
I've never seen that operator used in JavaScript before. Are you sure it is not supposed to be !==? That is a comparison operator that means not equal to the value and the type. -- is a decrement operator. ! usually just means not.

There may be a JavaScript framework that uses that to increment, maybe? Can you share a small code snippet that is using that operator? That could help clear it up.
Sheldon Poon
1
0
Sheldon Poon Entrepreneur
Technical Director, Drive Marketing
can you give us the context in which the !-- was used? <!-- means 'begin comment' in html
Fabio Nagao
1
0
Fabio Nagao Entrepreneur
Owner, Become Evolved
When applied in an integer decrementing variable (otherwise no reason for -- unary operator), !--x is false until x === 0 because of the falsy nature of 0.
You are 100% right when you are saying it's just a way to confuse the next person maintaining the system, its just a hipster way of asking x === 0 ?. So:

!2 = false; !1 = false; !0 = true.

Hope it helps.
Garet Claborn
1
0
Garet Claborn Entrepreneur
CEO, Original Author at Approach Corporation
1. !-- May be related to HTML comments.
// <!--

code

// -->

If the code was corrupted somehow you could be left with !--



2. Is it being used as an operator, in a string, what? Could simply be an unenclosed string.


3. It's possible this is a typo of !== which means, a does not equal to the typed value of b.
David Rowell
3
0
David Rowell Entrepreneur
CEO & Founder at LifeLinker Inc
At the risk of sounding curmudgeonly, this is Founder Dating.

A technical low-level question about the syntax of a specific programming language has no place on the Founder Dating site. Surely it should be on Stack Overflow or any of the dozens of sites devoted to assisting with programming.
Brandon S
0
0
Brandon S Entrepreneur
UX Designer at REC1 Software
It doesn't do anything unless you're using it as a string "!--" or if you want to add a less than sign before to create a comment. Javascript, along with other programming languages such as php have commenting syntax which works as follows:

<script type="text/javascript">
<!--
// This is a single line JavaScript comment

document.write("I have comments in my JavaScript code!");
//document.write("You can't see this!");
//-->
</script>

Dan Dascalescu
0
0
Dan Dascalescu Entrepreneur
Developer Advocate at Google
What David said. This question belongs on the JavaScript StackOverflow chat.
Join FounderDating to participate in the discussion
Nothing gets posted to LinkedIn and your information will not be shared.

Just a few more details please.

DO: Start a discussion, share a resource, or ask a question related to entrepreneurship.
DON'T: Post about prohibited topics such as recruiting, cofounder wanted, check out my product
or feedback on the FD site (you can send this to us directly info@founderdating.com).
See the Community Code of Conduct for more details.

Title

Give your question or discussion topic a great title, make it catchy and succinct.

Details

Make sure what you're about to say is specific and relevant - you'll get better responses.

Topics

Tag your discussion so you get more relevant responses.

Question goes here

1,300 Followers

  • Name
    Details
  • Name
    Details
  • Name
    Details
  • Name
    Details
  • Name
    Details
  • Name
    Details
  • Name
    Details
  • Name
    Details
Know someone who should answer this question? Enter their email below
Stay current and follow these discussion topics?