Evgenij Reznik
Evgenij Reznik

Reputation: 18614

Join is not a function

I'm playing around with PEG.js

start = keyword

keyword = a:[a-z]? {return a.join("");}

Why am I getting here the error:

a.join is not a function

when I enter a valid string like abc?

Upvotes: 18

Views: 60034

Answers (2)

Muhammad Awais
Muhammad Awais

Reputation: 1996

I was facing this error when I was applying join function and then returning the result in the same string array variable, we cannot do that we should save the result in some other string type variable

Upvotes: 0

misantronic
misantronic

Reputation: 1211

join() is an array-function, you cannot use it on a string: https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Array/join

Upvotes: 24

Related Questions