Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 443
Evgenij Reznik Avatar asked Oct 31 '15 11:10

Evgenij Reznik


People also ask

Is not function?

The NOT Function[1] is an Excel Logical function. The function helps check if one value is not equal to another. If we give TRUE, it will return FALSE and when given FALSE, it will return TRUE. So, basically, it will always return a reverse logical value.

Is not a function meaning?

The JavaScript exception "is not a function" occurs when there was an attempt to call a value from a function, but the value is not actually a function.

How do I join JavaScript?

join() The join() method creates and returns a new string by concatenating all of the elements in an array (or an array-like object), separated by commas or a specified separator string. If the array has only one item, then that item will be returned without using the separator.

How do I convert a string to an array in JavaScript?

The split() method splits a string into an array of substrings. The split() method returns the new array. The split() method does not change the original string. If (" ") is used as separator, the string is split between words.


1 Answers

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

like image 178
misantronic Avatar answered Oct 21 '22 07:10

misantronic