My Javascript gives syntax error in Chrome and Safari but does not give error in Firefox?

Asked

Viewed 380 times

4

These are my files:

    <script type="text/javascript" src="js/jquery-1.9.1.js"></script>
    <script type="text/javascript" src="js/jquery-ui.js"></script>
    <script type="text/javascript" src="js/bootstrap.min.js"></script>
    <script type="text/javascript" src="js/bootstrap-collapse.js"></script>
    <script type="text/javascript" src="js/bootstrap-tab.js"></script>
    <script type="text/javascript" src="js/jquery.mCustomScrollbar.concat.min.js"></script>
    <script type="text/javascript" src="js/custom.js"></script>

I have the following problem:

Mozilla Firefox works perfectly. Chrome and Safari don’t run at all. Error:

Uncaught Syntaxerror: Unexpected token > custom.js:401

Has this problem ever occurred with someone?

  • There is some error in the console?

  • Be more descriptive, what error is occurring ? In the Chrome Debug Console (F12) some message is appearing ?

  • Uncaught Syntaxerror: Unexpected token > custom.js:401 Event.returnValue is deprecated. Please use the standard Event.preventDefault() Instead. jquery-1.9.1.js:3345

  • 1

    You can post here the content of custom.js? Hmmm, by the way, looks pretty big. You can take a look near line 401?

  • 2

    And put the error in the question by editing it? It’s easier for other people to understand the problem.

  • in your browser, press Crtl+Shift+I and note if an error appears in the Console tab. And Update your question with the errors you find there. Telling you the content of your custom.js and what you’re looking to do will be helpful enough for us to help you

  • 1

    Jefferson, that is great! so you can edit the question and ask an answer, or delete the question :) If you have more problems there are many people here who want to help

Show 2 more comments

1 answer

4

I found the mistake.

On line 401 of my custom.js file I made a condition with the logical operator "Greater or Equal" like this:

=>

the right thing to do:

>=

But I found it strange that in Firefox ran normally.

  • 1

    Firefox is similar to javascript, it runs things that weren’t meant to run. It’s sad..

  • 7

    Firefox supports a section called Arrow functions, provided in the next version of the language (Coffeescript already uses). You were unlucky to bump into it.

  • 2

    @bfavaretto note that the Arrow functions of ES6 are not identical to CS fat Arrow, for example, currently the ES6 syntax requires a list of parameters -- (a,b) => {} or a => {} -- while CS has no problem hiding the parameter list. This was discussed in TC39 September/2013 meeting but it seems that most members want to keep the list of mandatory parameters, although there has been no consensus.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.