1var str = "<b>Bob</b>, I'm <b>20</b> years old, I like <b>programming</b>.";
2
3var result = str.match(/<b>(.*?)<\/b>/g).map(function(val){
4 return val.replace(/<\/?b>/g,'');
5});
6//result -> ["Bob", "20", "programming"]
1// Using ES2015+ fat-arrow-function syntax
2const getTextOfElement = () => {
3 const element = document.getElementById('elementId'); // Get desired HTML element
4 console.log(element.textContent); // Get text of element & display in console
5}