Syntax Error in creating javascript constructor function

79 views Asked by At

I am trying to create a constructer function as follows in javascript. But i get the error:

SyntaxError: Unexpected token ILLEGAL

I am getting this when i run the following in chrome developer tools console:

function People () {
​this.superstar = "Michael Jackson";
}

Is there any syntax error in the same. If not then whats causing the error.

1

There are 1 answers

2
juvian On BEST ANSWER

You probably have a weird invisible character there, but rewriting it works fine:

function People(){
    this.superstar = "Michael Jackson";
}