Chapter 3. JScript Essentials

JScript is Microsoft's version of JavaScript. If you are familiar with Java or JavaScript, you'll be able to jump right into the swing of things with JScript. Many advanced programmers prefer JScript to VBScript. JScript offers more features and more control over many elements of your scripts. More features and controls also mean that, in some ways, JScript is more complex than VBScript.

Variables and Data Types

Like VBScript, JScript allows you to work with constants and variables. Constants are distinguished from variables in that their values do not change within the program.

Variables and naming conventions

JScript variable names are case-sensitive, which means valueA, ValueA, and VALUEA all refer to different variables. Variable names can include alphabetic and numeric characters as well as the underscore (_) character, but must begin with an alphabetic character or the underscore character. Further, variable names cannot include spaces or punctuation characters. Using these variable-naming rules, the following are all valid names for variables:

myvar
user_name
_varA
theAnswer

Unlike VBScript, the case-sensitivity rule applies to all objects in JScript. This means you can't call WScript using anything but WScript and that all of the following statements result in errors:

wscript.echo("This ...

Get Microsoft® PowerShell, VBScript and JScript® Bible now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.