Make Array.join ignore null values (fix #289)

This commit is contained in:
Gordon Williams 2014-04-07 12:56:55 +01:00
parent 5c491c38c9
commit 40a989c25c
3 changed files with 6 additions and 2 deletions

View File

@ -2,6 +2,7 @@
Support floating-point literals without a leading 0 - eg '.5' (fix #296)
Fix array access with booleans (fix #290)
Fix "==" issues where only one argument is an array (fix #283)
Make Array.join ignore null values (fix #289)
1v60 : Fix unary plug on variable not working (fix #268)
Added DNS with eth.setIP() for W5500

View File

@ -1863,7 +1863,7 @@ JsVar *jsvArrayJoin(JsVar *arr, JsVar *filler) {
}
// add the value
JsVar *value = jsvIteratorGetValue(&it);
if (value) {
if (value && !jsvIsNull(value)) {
JsVar *valueStr = jsvAsString(value, true /* UNLOCK */);
if (valueStr) { // could be out of memory
jsvAppendStringVarComplete(str, valueStr);

View File

@ -1,4 +1,7 @@
// test for array join
var a = [1,2,4,5,7];
result = a.join(",")=="1,2,4,5,7";
// https://github.com/espruino/Espruino/issues/289
var b = ["true", undefined, true, null];
result = a.join(",")=="1,2,4,5,7" && b.join()=="true,,true,";