Markdown:
Social:
network
??. It is stackable.
$expr1 ?? $expr2 ?? $expr3 returns the first non-false expression.?>.
expr1?:expr3.
instead of only the first (which is the default behaviour of str = str.replace()).
This is achieved by using RegEx with the global flag. However this means to take extra care of RegEx special chars in the find text (needle).
Solution from Stackoverflow:
function escapeRegExp(str) {
return str.replace(/([.*+?^=!:${}()|\[\]\/\\])/g, "\\$1");
}var str = '<p>any|other text, any occurrence</p>';
str = str.replace(new RegExp(escapeRegExp("any"), 'g'), "another");Covered by Code Maven.
You can "print" JavaScript objects to the browser console via console.log('Something:', myobject). Some browsers do not print the result, but reference the view to it. If the object is changed during runtime, only the last version will be displayed for each console.log call, no matter where you position the calls in your code. [Actually, you might circumvent this by adding wait time during the different calls or set breakpoints but that seems tedious under most circumstances.]
Solution: Convert the object to a string and back before printing it.
var myObject = {
'id' : 1,
'name' : 'Test'
};
console.log("My Object: ", JSON.parse(JSON.stringify(myObject)));