You are here: Ultra Guide>Main Web>JavaScriptTutorial (03 Aug 2020, BenRosner)Edit AttachTags

Data Types

There are many data types in JavaScript, similar to any other coding language. These include numbers, strings, objects, arrays, booleans, etc. We will run down a brief synopsis of the major data types.

Strings

A string is a series of characters wrapped inside quote marks. You can use either single or double quotes. You can use quotes inside a string, as long as they don't match the quotes surrounding the string. An example of a string would be something like: "Utranauts".

Integers

JavaScript has only one type of integer. Integers can be written with or without decimals. Extra large or extra small integers can be written with scientific notation. An example of an integer would be 3724.

Booleans

Booleans are a data type that illustrates either a true or false statement. They are often used in conditional testing. They must evaluate to either True or False. An example of a boolean statement would be 4 > 2. That expression would evaluate to True given that the integer 4 is greater in value than the integer 2.

Arrays

Arrays in JavaScript are written is square brackets. They are a collection of values that can include either strings, integers or booleans. Array items are separated by commas. Array indexes are zero-based, which means the first item is [0], second is [1], and so on. An example of an array would be: [4, 2, "ultranauts"].


Objects

JavaScript objects are written with curly braces {}. Object properties are written as name value pairs, with the name and value separated with a colon. An example of an object would be something like this:

const Ultranaut = {firstName: "Ben", lastName: "Rosner", age: 28, eyeColor: "blue"}

As you can see the name value pairs are separated by commas, and like an array, can hold a combination of strings, integers, or booleans.



-- BenRosner - 31 Jul 2020
Topic revision: r2 - 03 Aug 2020, BenRosner
© 2020 Ultranauts - 75 Broad Street, 2nd Floor, Suite 206, New York, NY 10004 - info@ultranauts.co