Apple Developer Connection
Advanced Search
Member Login Log In | Not a Member? Contact ADC

< Previous PageNext Page >

データ型

JavaScriptでは、Table 1-1に示すとおり、5つの基本型があります。

Table 1-1  JavaScriptにおける基本型

説明

number

数値。整数および浮動小数点の値の処理が可能。

boolean

論理値。trueまたはfalseのどちらか。

string

文字の並び。

null

値なし。

undefined

値は不明。

JavaScriptでは、必要に応じて型を自由に変換できます。次のような文があるとします。

var x = 1 + "2";

JavaScriptはまず文字列"2"を数値の2に変換し、3という数値をxに代入します。

基本型以外のものはすべてオブジェクトです。基本型は、次のように必要に応じてオブジェクトに昇格されます。

var message = "Hello World";
var firstCharacter = message.charAt(0);

JavaScriptは、charAtメンバ関数を呼び出すために、文字列"Hello World"をオブジェクトに昇格します。



< Previous PageNext Page >


Last updated: 2007-06-11




Did this document help you?
Yes: Tell us what works for you.

It’s good, but: Report typos, inaccuracies, and so forth.

It wasn’t helpful: Tell us what would have helped.
Get information on Apple products.
Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Copyright © 2007 Apple Inc.
All rights reserved. | Terms of use | Privacy Notice