No.1ベストアンサー
- 回答日時:
Perl殆どやってないけどね。
規格を読んで見ましょうか。(該当部分は抜き出すけど訳さないよ)
BNFは習得済みとします。
http://www.atmarkit.co.jp/fxml/ddd/ddd004/ddd004 …
ECMA-262
http://www.ecma-international.org/publications/s …
11.3 Postfix Expressions
Syntax
Postfix Expression :
LeftHandSideExpression
LeftHandSideExpression [no LineTerminatorhere] ++
LeftHandSideExpression [no LineTerminatorhere] --
11.3.1 Postfix Increment Operator
The production PostfixExpression : LeftHandSideExpression [no LineTerminator here] ++ is evaluated as
follows:
1. Evaluate LeftHandSideExpression.
2. Call GetValue(Result(1)).
3. Call ToNumber(Result(2)).
4. Add the value 1 to Result(3), using the same rules as for the + operator (see 11.6.3).
5. Call PutValue(Result(1), Result(4)).
6. Return Result(3).
================================
9.3.1 ToNumber Applied to the String Type
ToNumber applied to strings applies the following grammar to the input string. If the grammar
interpret the string as an expansion of StringNumericLiteral, then the result of ToNumber is NaN.
================================
11.6.3 Applying the Additive Operators ( +,- ) to Numbers
The + operator performs addition when applied to two operands of numeric type, producing the sum of
the operands. The - operator performs subtraction, producing the difference of two numeric operands.
Addition is a commutative operation, but not always associative.
The result of an addition is determined using the rules of IEEE 754 double-precision arithmetic:
* If either operand is NaN, the result is NaN.
(以下略)
=====================================
11.8.3 The Less-than-or-equal Operator ( <= )
The production RelationalExpression : RelationalExpression <= ShiftExpress
1. Evaluate RelationalExpression.
2. Call GetValue(Result(1)).
3. Evaluate ShiftExpression.
4. Call GetValue(Result(3)).
5. Perform the comparison Result(4) < Result(2). (see 11.8.5).
6. If Result(5) is true or undefined,return false.Otherwise,return true.
=========================================
11.8.5 The Abstract Relational Comparison Algorithm
The comparison x < y,where x and y are values, produces true, false,or undefi
at least one operand is NaN). Such a comparison is performed as follows:
(以下略)
================
よって
var i = "A";
i++;
を実行すると
【iはNaNになります。】
i < 'Z';
は片方がNaNであればNaNとなります。
====================
9.3
ToBoolean
The operator ToBoolean converts its argument to a value of type Boolean according to the following table:
(略)
The resultis false if the argumentis +0, -0,or NaN;otherwise the resultis true.
======================
12.6.3 The for Statement
(略)
The production IterationStatement : for ( var VariableDeclarationListNoIn ; Expressionopt ;
Expressionopt ) Statement is evaluated as follows:
1. Evaluate VariableDeclarationListNoIn.
2. Let V = empty.
3. If the first Expression is not present, go to step 8.
4. Evaluate the first Expression.
5. Call GetValue(Result(4)).
6. Call ToBoolean(Result(5)).
7. If Result(6) is false,gotostep14.
8. Evaluate Statement.
9. If Result(8).value is not empty, let V = Result(8).value.
10.If Result(8).type is break and Result(8).target is in the current label set, go to step 17.
11.If Result(8).type is continue and Result(8).target is in the current label set, go to step 13.
12.If Result(8) is an abrupt completion, return Result(8).
13.If the second Expression is not present, go to step 3.
14.Evaluate the second Expression.
15.Call GetValue(Result(14)). (This value is not used.)
16.Go to step 3.
17.Return (normal,V, empty).
===================
ということで2回目の真ん中はNaNはfalseで,右側が実行されるだけで,中身は実行されません
結果として最初の1回だけ実行されるんですね。
=====================
さて,解決策ですが,ASCII互換のUnicodeではAからZは連続しているので
15.5.3.2 String.fromCharCode([char0[,char1[,…]]])
Returns a string value containing as many characters as the number of arguments. Each argument
specifies one character of the resulting string, with the first argument specifying the first character,
and so on, from left to right. An argument is converted to a character by applying the operation
ToUint16 (9.7) and regarding the resulting 16-bit integer as the code point value of a character. If no
arguments are supplied, the result is the empty string.
The length property of the fromCharCode function is 1.
15.5.4.5 String.prototype.charCodeAt (pos)
16
Returns a number (a nonnegative integer less than 2 ) representing the code point value of the
character at position pos in the string resulting from converting this object to a string. If there is no
character at that position, the result is NaN.
When the charCodeAt method is called with one argument pos, the following steps are taken:
1. Call ToString, giving it the this value as its argument.
2. Call ToInteger(pos).
3. Compute the number of characters in Result(1).
4. If Result(2) is less than 0 or is not less than Result(3), return NaN.
5. Return a value of Number type, whose value is the code point value of the character at position
Result(2) in the string Result(1), where the first (leftmost) character in Result(1) is considered to
be at position 0, the next one at position 1, and so on.
の二つを元に
for (var i = "A".charCodeAt(0);i <= "Z".charCodeAt(0);i++){
document.writeln(String.fromCharCode(i));
}
という形で書けば,ソースコード上にAからZまで改行区切りで出力されます(lnがなければ,改行されない)
HTMLとソース中の空白文字類とCSSの関係(改行しているように見えないんだけどーとか聞くな)
CDATAマーク区間の話
document.writelnの仕様(DOM Level 2 HTML,HTML5)
7.8.4 String Literals
prototypeとは何か
については説明しません。
この回答へのお礼
お礼日時:2009/09/22 05:01
ありがとうございます。
今回は
var aa='A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z'.split(',');
としました。
配列のすることが狙いだったので不細工ですが案外短かったので
これでいきました。
ご提示の方法は応用が効くので参考にします。
お探しのQ&Aが見つからない時は、教えて!gooで質問しましょう!
似たような質問が見つかりました
- JavaScript 1日1回引けるJavaScriptおみくじについて 1 2022/12/12 22:28
- C言語・C++・C# C言語の質問です HTMLでこのようなコードを書いたのですがそれをC言語で同じように書きたいです < 1 2022/08/11 23:38
- JavaScript JAVASCRIPT 2 2022/04/15 15:10
- JavaScript jQueryでのドラッグアンドドロップについて 1 2022/07/07 21:04
- JavaScript セレクトボックスで配列を呼び出したい。 1 2022/07/08 20:14
- JavaScript 画像の表示位置 3 2022/12/23 08:25
- JavaScript jQueryでのドラッグアンドドロップについて 1 2022/07/30 09:10
- JavaScript javascript作成してます。ラジオボタンで判定するコードを書いてます。 1 2023/07/18 11:03
- JavaScript WordPressのコンタクトフォーム7にて送信者の位置情報を送らせたい 2 2022/09/14 23:28
- JavaScript ①入力フォーム→②確認表示画面→③送信完了画面のコードを書いているのです、 入力フォームから受け取っ 2 2022/05/10 16:45
関連するカテゴリからQ&Aを探す
おすすめ情報
デイリーランキングこのカテゴリの人気デイリーQ&Aランキング
-
return trueとreturn falseの用...
-
未入力のラジオボタンに、alert...
-
onSubmit=の後ろは複数可能でし...
-
slickのレスポンシブ > center...
-
TEXTAREAに入力した改行コード...
-
未選択のチェック方法を教えて...
-
フォームの入力チェックをする...
-
!!winVar
-
度胸試しのJavaScript
-
コピペを禁止するtextarea
-
<JavaScript>tableタグを入力不...
-
【jQuery】input nameの文字列...
-
onchangeイベントを強制的に発...
-
javascriptでASPにデータを渡す
-
プルダウン選択を変更すると、...
-
二つの入力欄に、同時に同じ文...
-
ラジオボタンにタブインデック...
-
ラジオボタンのチェックが外れ...
-
別ウィンドウへのsubmitの挙動...
-
Selectボックスの一覧表示方法
マンスリーランキングこのカテゴリの人気マンスリーQ&Aランキング
-
return trueとreturn falseの用...
-
slickのレスポンシブ > center...
-
ラジオボタンのNullチェック
-
COBOLの数字チェック
-
未入力のラジオボタンに、alert...
-
JavaScriptde途中で、「exit」...
-
正規表現で複数マッチ条件で悩...
-
コピペを禁止するtextarea
-
ツリービューのチェックボック...
-
フォームの入力チェックをする...
-
度胸試しのJavaScript
-
Visual Studioのデザインでの非...
-
一度しか押せないボタンについて
-
onSubmit=の後ろは複数可能でし...
-
form の onSubmit がコールされ...
-
チェックボックスの有無判定
-
テキストボックスに数字しか入...
-
変数の値によってsubmit後の動...
-
ドラッグ&ドロップ禁止について
-
IE7のJavascriptで return fals...
おすすめ情報