Is there an easy way to take a string of html in JavaScript and strip out the html?...
How do I make the first letter of a string uppercase, but not change the case of any of the other letters?  For example:   "this is a test" -> "This is a test" "the Eiffel Tower" -> "The Eiffel Tower" "/ind...
How can I count the number of times a particular string occurs in another string. For example, this is what I am trying to do in Javascript:  var temp = "This is a string."; alert(temp.count("is")); //should output '2'...
I need javascript to add 5 to an integer variable, but instead it treats the variable as a string, so it write out the variable, then add 5 onto the end of the "string". How can I force it to do math instead?  var dots = document.getElement...
I know in PHP we can do something like this:  $hello = "foo"; $my_string = "I pity the $hello";   Output: "I pity the foo"  I was wondering if this same thing is possible in JavaScript as well. Using variables inside strings...
How do I parse and evaluate a mathematical expression in a string (e.g. '1+1') without invoking eval(string) to yield its numerical value?  With that example, I want the function to accept '1+1' and return 2....
I'm trying to replace multiple words in a string with multiple other words. The string is "I have a cat, a dog, and a goat."  However, this does not produce "I have a dog, a goat, and a cat", but instead it produces "I have...
Taken from MDN     String literals (denoted by double or single quotes) and strings   returned from String calls in a non-constructor context (i.e., without   using the new keyword) are primitive strings. JavaScript automatically   converts primiti...
How can I convert a JavaScript object into a string?  Example:  var o = {a:1, b:2} console.log(o) console.log('Item: ' + o)   Output:     Object { a=1, b=2} // very nice readable output :)   Item: [object Object] // no idea what's insid...
What is the best or most concise method for returning a string repeated an arbitrary amount of times?  The following is my best shot so far:  function repeat(s, n){     var a = [];     while(a.length < n){         a.push(s);     }     return a.j...

Tags

Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.