IT SOLUTIONS
Your full service technology partner! 
+Expand
   ► KBTo/From GuidesJavaScript  Print This     

Variables (JavaScript and C++ Cross Reference Guide)

By Mike Prestwood

JavaScript versus C++: A side by side comparison between JavaScript and C++.

 
Language Basics
 

Language basics is kind of a catch all for absolute beginner stuff. The items (common names) I chose for language basics is a bit random and include items like case sensitivity, commenting, declaring variables, etc.

Variables

[Other Languages] 

Languages Focus

A variable holds a value that you can use and change throughout your code so long as the variable is within scope. With variable declaration, you not only want to know the syntax of how you declare a variable but you also want to know where. Are you allowed to declare a variable inline? What are the available scopes: local vs. global. Can you assign a value at the same time you declare a variable?

JavaScript:   var x = 0;

JavaScript is a loosely typed language. Each variable is cast in usage as string, number, boolean, function, or object.

Variable names are case sensitive.

Alternatively, you can specify the value when you declare a variable:

var FirstName = "Mike";
var LastName = "Prestwood";
var Age = 42;
Syntax Example:
var FirstName;
var LastName;
var Age;
C++:   int x=0;

Variable names are case sensitive.

The fundamental variable types in C++ are char, short int, int, long int, bool, float, double, long double, and wchar_t. The integer data types char, short, long and int can be either signed or unsigned. Signed variables are positive and negative. Unsigned variables are positive only.

Syntax Example:

C++, Java, and C# all use C-like variable declaration.

int Age;
int Age = 43;
float a, b, c;
string FullName; //#include 
unsigned short int FamilyMemberCount;












Go ahead!   Use Us! Call: 916-726-5675  Or visit our new sales site: 
www.prestwood.com


©1995-2025 Prestwood IT Solutions.   [Security & Privacy]