質問

I am getting the output of an array in the following format:

[ "12", "13", "14", "25", "7" ]

I was wondering if there's a way to change the separator to a pipe (|), and store the whole string in a variable. I would also need to check if each the value is the object in the array has a value different from "null" or "false".

Thank you!!!

役に立ちましたか?

解決

You can do:

arr = arr.join("|");

quick demo: http://jsfiddle.net/hUGg5/

To actually do some checking:

arr = arr.filter(function(i) {
    if (i != null || i != false)
        return i;
}).join("|");
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top