如何将数组转换为字符串

时间:2020-05-07 12:24:12

标签: javascript arrays

我有一个像这样的数组-

private CancellationTokenSource _cts = null;
...
dataGrid.SelectionChanged += async(ss, ee) =>
{
    //cancel any previous long running operation
    if (_cts != null)
    {
        _cts.Cancel();
        _cts.Dispose();
    }
    _cts = new CancellationTokenSource();
    //store a local copy the unique id or something of the currently selected item
    var id = (dataGrid.SelectedItem as TestItem).Id;
    //wait a second and a half before doing anything...
    await Task.Delay(1500);
    //if no other item has been selected since {id} was selected, call the long running operation
    if (_cts != null && id == (dataGrid.SelectedItem as TestItem).Id)
    {
        try
        {
            await LongRunningOperation(id, _cts.Token);
        }
        finally
        {
            _cts.Cancel();
            _cts.Dispose();
            _cts = null;
        }
    }
};

我想要这样的字符串输出-

var arr = ['This', 'is', 'array']

1 个答案:

答案 0 :(得分:-1)

只需使用join()数组方法-

const string = arr.join(' ');