小编Łuk*_*zak的帖子

使用函数`String()`和函数参数的目的是什么?

我正在读书'Singe Page Web Applications'.我遇到了以下示例:

// This is single pass encoder for html entities and handles
// an arbitrary number of characters
encodeHtml = function ( input_arg_str, exclude_amp) {
    var input_str = String( input_arg_str), regex, lookup_map;

    ...

    return input_str.replace(regex, function ( match, name ){
        return lookup_map[ match ] || '';
    });
};
Run Code Online (Sandbox Code Playgroud)

我想知道,使用String()带参数的函数的目的是什么input_arg_str.我知道通过使用String()函数我可以将不同的对象转换为字符串,但我从未遇到过使用这样的功能String().

我很好奇你对此的看法,并且非常感谢你的帮助.

javascript

1
推荐指数
1
解决办法
94
查看次数

标签 统计

javascript ×1