一些老旧的字符串方法

看到这篇文章:Legacy String Methods for Generating HTML,很有意思。

我们在操作字符串时,使用的多是一些常用的方法。但你了解所有的字符串方法吗?有些已经有年头,不推荐使用了。mdn文档字符串篇,那些带有“删除”标志的方法都是这种情况。大部分方法都是用来快速创建html字符串的。

因为向后兼容的原因,这些方法并没有从String.prototype上删除。


'anchor'.anchor('name');//<a name="name">anchor</a>
'big'.big();//<big>big</big>
'blink'.blink();//<blink>blink</blink>
'bold'.bold();//<b>bold</b>
'fixed'.fixed();//<tt>fixed</tt>
'fontcolor'.fontcolor('red');//<font color="red">fontcolor</font>
'fontsize'.fontsize(16);//<font size="16">fontsize</font>
'italics'.italics();//<i>italics</i>
'link'.link('https://robberfree.github.io');//<a href="https://robberfree.github.io">link</a>
'small'.small();//<small>small</small>
'strike'.strike();//<strike>strike</strike>
'sub'.sub();//<sub>sub</sub>
'sup'.sup();//<sup>sup</sup>