transfrom code from php to javascript : How to transform the following code from php to javascript?

    $str = '';
    for ($i = 0; $i < 256; $i++) {
        $str .= chr($i);
    }

I know String.fromCharCode() in javascript is similar to chr() in php, but it seems fromCharCode(n) is diffenent from chr(n) when n greater than 127.
