Hey there,

Why does the function compact not work for me? it is a function according to the javascript documentation.

The problem is, however; if I add the brackets after it, the browser complains for some reason and it says compact is NOT a function. Also, with the function parseInt, it doesn't take brackets after it. Isn't it a function?

I thought functions should always have brackets inserted after thier names like java and php.

  var drinks = ["pepsi", "coke", "juice", null];



6 Years
Discussion Span
Last Post by Taywin

it is a function according to the javascript documentation.

According to which documentation?


Which of course is talking about the functions defined in that library and makes no claim about that function being available as part of Javascript itself.


If it is really a function, then try drinks.compact() instead. Using drinks.compact means you are calling for the value of its local variable named 'compact'.


There's no JS built in method named "compact" in Array object or any other js Object for that matter.
What does it mean anyway?

What should >>array.compact<< do with it, to your understanding ?


If I add brackets after array.compact, then it doesn't work! The komodo IDE says that it returns the array without undefined or null elements.

Is there a good API catalog that I can download and import into my IDE?


I already told you: there is no [].compact method in JavaScript Array Object(s).
And sorry, I don't use "komodo" nor anything of that kind.

Have you at least tried it without brackets?!

Edited by Troy III


If it is really a function

And as I said "If it is really a function" means if the compact() is a function for the object you are calling for. If it is not, it would return undefined instead. By the way, you could implement the function to the object as well. I am not sure what compact() functionality you are looking for.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.