Home > Web Front-end > JS Tutorial > JavaScript implementation of storing HTML string example_javascript skills

JavaScript implementation of storing HTML string example_javascript skills

WBOY
Release: 2016-05-16 16:51:46
Original
1103 people have browsed it

I work in PHP, and it reminds me of <<< syntax (heredoc and nowdoc), so let’s name it heredoc.

Copy code The code is as follows:

Function.prototype.heredoc = function(){
//Use function comments to store strings without escaping.
var _str = this.toString(),
s_pos = _str.indexOf("/*") 2,
e_pos = _str.lastIndexOf("*/");
return (s_pos< 0 || e_pos<0) ? "" : _str.substring(s_pos, e_pos);
}

function fn(){
/*







Username Password
@name zf123456
*/
}

var str_table = fn.heredoc();
console.log(str_table);

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template