String.prototype.bold() is a deprecated HTML-wrapper method retained for compatibility. Do not use it for new code. Use semantic HTML such as <strong>, CSS, or DOM APIs instead.
const text = "Important";
console.log(text.bold()); // legacy: <b>Important</b>
string.bold()The method returns an HTML string; it does not style the original JavaScript string object.
const text = "Welcome to Plus2net";
const htmlText = text.bold();
console.log(htmlText);
If the text has strong importance, write <strong>Important</strong> directly in HTML.
const strong = document.createElement("strong");
strong.textContent = "Important";
document.body.append(strong);Using textContent avoids interpreting the text itself as HTML.
.emphasis { font-weight: 700; }Use CSS when the effect is visual rather than semantic.
Do not build user-supplied HTML with deprecated wrapper methods and then insert it with innerHTML. Prefer DOM creation and textContent.
Previous / String Reference Next related topic
Author & Instructor at plus2net
I write and maintain practical tutorials on Python, PHP, SQL, JavaScript, HTML, jQuery, and web development at plus2net. The tutorials focus on clear explanations, working examples, and code that readers can test and adapt while learning.