Javascript String m(s)

Description

Javascript String m(s)


String.prototype.m = function(s) {
    return this.indexOf('a');
};

var g = function(s) {
    return (s + 'asdf').m();
};

var h = function(s) {
    return ('asdf' + s).m();
};

var ix = g(new String('abc'));
assertEq(ix, 0);//w w  w  . ja  v  a2s  .c o m

var ix = h(new String('abc'));
assertEq(ix, 0);



PreviousNext

Related