New JScript .NET Data Types

Learn about the data types that JScript .NET provides.

provided by: 
Originally published at Internet.com


JScript has a limited set of data types: Number, String, Boolean, and Object. The JScript interpreter works behind the scenes to coerce, or convert, data stored in variables into one of its native types using a standard set of rules (see section nine of the ECMAScript Language Specification). For example, the listing below uses the typeof operator to demonstrate that one variable can manage several data types (you can view the sample here) var a; a = 5; // typeof(a) returns 'number' a = "five"; // typeof(a) returns 'string' a = false; // typeof(a) returns 'boolean' a = new String("");// typeof(a) returns 'object'

The key benefit the JScript interpreter provides is that is makes code easier to write since it performs data type conversions for you. The key drawback is that the JScript interpreter can end up working against the developer in situations like the one I demonstrated last week (where the interpreter seems to unexpectedly change a data type from one type to another) - here's the code again: a = 1; b = "1"; a += b; // what is the value of a?

If you guessed that the value of a should be two, you're wrong. Based on the data type conversion rules in the ECMAScript standard, JScript evaluates both operands (a and b) and determines that one of them, b, is a String (based on the value that's assigned to b). Since there's a String involved in the operation (+ in this example), JScript converts a into a String and concatenates b to it. The result is that a is 11 - it's not new math, the result is the String "11"...

Read article at Internet.com site
Regional Articles
- New JScript .NET Data Types Alabama
- New JScript .NET Data Types Alaska
- New JScript .NET Data Types Arizona
- New JScript .NET Data Types Arkansas
- New JScript .NET Data Types California
- New JScript .NET Data Types Colorado
- New JScript .NET Data Types Connecticut
- New JScript .NET Data Types DC
- New JScript .NET Data Types Delaware
- New JScript .NET Data Types Florida
- New JScript .NET Data Types Georgia
- New JScript .NET Data Types Hawaii
- New JScript .NET Data Types Idaho
- New JScript .NET Data Types Illinois
- New JScript .NET Data Types Indiana
- New JScript .NET Data Types Iowa
- New JScript .NET Data Types Kansas
- New JScript .NET Data Types Kentucky
- New JScript .NET Data Types Louisiana
- New JScript .NET Data Types Maine
- New JScript .NET Data Types Maryland
- New JScript .NET Data Types Massachusetts
- New JScript .NET Data Types Michigan
- New JScript .NET Data Types Minnesota
- New JScript .NET Data Types Mississippi
- New JScript .NET Data Types Missouri
- New JScript .NET Data Types Montana
- New JScript .NET Data Types Nebraska
- New JScript .NET Data Types Nevada
- New JScript .NET Data Types New Hampshire
- New JScript .NET Data Types New Jersey
- New JScript .NET Data Types New Mexico
- New JScript .NET Data Types New York
- New JScript .NET Data Types North Carolina
- New JScript .NET Data Types North Dakota
- New JScript .NET Data Types Ohio
- New JScript .NET Data Types Oklahoma
- New JScript .NET Data Types Oregon
- New JScript .NET Data Types Pennsylvania
- New JScript .NET Data Types Rhode Island
- New JScript .NET Data Types South Carolina
- New JScript .NET Data Types South Dakota
- New JScript .NET Data Types Tennessee
- New JScript .NET Data Types Texas
- New JScript .NET Data Types Utah
- New JScript .NET Data Types Vermont
- New JScript .NET Data Types Virginia
- New JScript .NET Data Types Washington
- New JScript .NET Data Types West Virginia
- New JScript .NET Data Types Wisconsin
- New JScript .NET Data Types Wyoming

Rss   Delicious   Digg   Add To My Yahoo   Add To My Google   Bookmark   Search Plugin

Topics:
Architecture & Design Languages & Tools Project Management Web Services
Database Microsoft & .NET Security Wireless
Java Open Source Techniques XML