Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Syntax error: unexpected token "-"

I'm doing a web application, and when I started writing the code in JavaScript I'm getting this error:

Syntax error: unexpected token "-"  javascript 

I'm using Aptana Studio 3. I thought it was Aptana's problem, so then I tried with Eclipse, but still got the same error. Eclipse shows me this error:

Cannot return from outside a function or method.

Here's my function:

function www_ebest_eu_company_node_service_task-slot-info () {
    this.typeMarker = 'www_ebest_eu_company_node_service_task-slot-info';
    this._endDateTime = null;
    this._number = null;
    this._orderId = null;
    this._startDateTime = null;
    this._taskId = null;
    this._taskStatus = null;
}

I have many functions like this, and for every of them I'm getting the same error.

Does anyone have the same problem?

like image 524
Totoro Avatar asked Dec 04 '22 18:12

Totoro


2 Answers

www_ebest_eu_company_node_service_task-slot-info is not a valid JavaScript identifier.

like image 183
leppie Avatar answered Dec 07 '22 06:12

leppie


You cannot use hyphens in JavaScript function names:

function www_ebest_eu_company_node_service_task-slot-info () {

// Should proabbly be
function www_ebest_eu_company_node_service_task_slot_info () {
//---------------------------------------------^^^^^^^^
like image 26
Michael Berkowski Avatar answered Dec 07 '22 08:12

Michael Berkowski