The selected() method, called without any parameters, will return all selected items' index of the ListBox widget.
The selected(index, bool) method is used to select or unselect(depending on second boolean parameter) particular item on the passed index position.

<div id="listbox" ></div>
<script type="text/javascript">
    $(function () {
            dataSource: {
			    data: countries
            textTemplate: "{name}",
            valueTempate: "{id}"

    $("#listbox").swidget().selected(); // return empty array
    $("#listbox").swidget().selected(0, true) // select the first item
    $("#listbox").swidget().selected(); // return array with one element - the selected item's index - 0