JavaScript String strike() Method
In JavaScript, the strike() method of the String object returns a new string that embeds the invoking string inside a <strike> element (<strike>str</strike>) which makes it appear as though this string is struck-out.
Note: This feature is no longer recommended as it has been deprecated, and only standardized for compatibility purposes.
Syntax
string.strike()
Return Value:
A string embedded within a <strike>
tag.
Parameters:
None.
Example 1: In the example below, we will see the basic usage of the strike()
method.
let str = "Hello, World!";
console.log(str.strike());
Output
<strike>Hello, World!</strike>
Example 2: In the example below, we will use the strike()
method with a concatenated string.
let str1 = "Hello, ";
let str2 = "World!";
console.log((str1 + str2).strike());
Output
<strike>Hello, World!</strike>
Example 3: In the example below, we will use nested HTML tags with the strike()
method.
let str = "Hello, <em>World!</em>";
console.log(str.strike());
Output
<strike>Hello, <em>World!</em></strike>