var arrValues = 'This is my string'.split('');
// Loop over each value in the array.
$.each(arrValues, function (intIndex, objValue) {
alert(objValue);
})
var i = str.length;
while (i--) {
alert(str[i]);
}
var str = 'This is my string';
function matters() {
for (var i = 0; i < str.length; i++) {
alert(str.charAt(i));
}
}
function dontmatter() {
var i = str.length;
while (i--) {
alert(str.charAt(i));
}
}
<p>If the order of alerts matters, use <a href="#" onclick="matters()">this</a>.</p>
<p>If the order of alerts doesn't matter, use <a href="#" onclick="dontmatter()">this</a>.</p>
var text = 'uololooo';
// With ES6
[...text].forEach(c => console.log(c))
// With the `of` operator
for (const c of text) {
console.log(c)
}
// With ES5
for (var x = 0, c=''; c = text.charAt(x); x++) {
console.log(c);
}
// ES5 without the for loop:
text.split('').forEach(function(c) {
console.log(c);
});
var string = 'A\uD835\uDC68B\uD835\uDC69C\uD835\uDC6A';
for (var v of string) {
alert(v);
}
// "A"
// "\uD835\uDC68"
// "B"
// "\uD835\uDC69"
// "C"
// "\uD835\uDC6A"
function myFunction() {
var text =(document.getElementById("htext").value);
var meow = " <p> <,> </p>";
var i;
for (i = 0; i < 9000; i++) {
text+=text[i] ;
}
document.getElementById("demo2").innerHTML = text;
}
</script>
<p>Enter your text: <input type="text" id="htext"/>
<button onclick="myFunction();">click on me</button>
</p>
const str = 'The quick red 🦊 jumped over the lazy 🐶! 太棒了!';
let iterator = str[Symbol.iterator]();
let theChar = iterator.next();
while(!theChar.done) {
console.log(theChar.value);
theChar = iterator.next();
}
// logs every unicode character as expected into the console.