0

I have a function:

function my_function_name()
    {
        var $obj = $my_object;
        var idx = Number($obj.order);
        var newIndex = idx+1;
    }

"newIndex" is NOT "idx + 1" but simply the same value as "idx". "$obj.order" is holding an integer value.

Any ideas what is going on?

4

1 回答 1

0

演示小提琴

function num(i) {
    this.order = i;
}


$my_object = new num(10);

var $obj = $my_object;
var idx = Number($obj.order);
var newIndex = idx + 1;

根据你的问题newIndex应该有10,但我正在11输出(见小提琴)

于 2013-03-21T20:09:33.403 回答