下記のhtml中のjsコードと出力において
出力結果の一行目に
空白文字が入ってしまいます。
なぜでしょうか?
javascript
1<!DOCTYPE html> 2<html lang="en"> 3<head> 4 <meta charset="UTF-8"> 5 <title>array_object</title> 6</head> 7<body> 8<pre> 9 <script type="text/javascript"> 10 var pushed_array = []; 11 pushed_array.push("きがあ"); 12 pushed_array.push(555); 13 pushed_array.push(269); 14 pushed_array.push('あああ'); 15 pushed_array.push('\"\"'); 16 pushed_array.push(222); 17 18 /**shiftで一個ずつ取り出す**/ 19 /* 20 console.log(pushed_array.shift()); 21 console.log(pushed_array.shift()); 22 console.log(pushed_array.shift()); 23 console.log(pushed_array.shift()); 24 console.log(pushed_array.shift()); 25 console.log(pushed_array.shift()); 26 */ 27 28 /**for of 構文の確認 **/ 29 Array.prototype.hoge=function () {} 30 for (var data of pushed_array) { 31 document.writeln(data); 32 document.write(data+'<br>'); 33 //document.write('<br>'); 34 } 35 </script> 36</pre> 37 38</body> 39</html> 40 41//出力結果 42 きがあ ←★ここです。 43きがあ 44555 45555 46269 47269 48あああ 49あああ 50"" 51"" 52222 53222 54
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
退会済みユーザー
2016/12/06 09:48