# jschap03 - Chapter 3 Data Types and Operators JavaScript...

This preview shows pages 1–18. Sign up to view the full content.

Chapter 3: Data Types and Operators JavaScript - Introductory

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Tutorial3Calculator.html
Section A: Using Data Types and Arrays

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Objectives In this section, students will learn: How to use data types About numeric data types About Boolean values How to use strings How to use arrays
Data Types Data type is the specific category of information that a variable contains Data types that can be assigned only a single value are called primitive types JavaScript supports five primitive data types: Integer numbers Floating-point numbers Boolean values Strings Null value

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Primitive Types
Data Types Programming languages that require you to declare the data types of variables are called strongly-typed programming languages Strong typing is also known as static typing Programming languages that do not require you to declare the data types of variables are called loosely-typed programming languages Loose typing is also known as dynamic typing since data types change after being declared

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Values Returned by Typeof () Operator
PrintDataTypes.html

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Numeric Data Types An integer is a positive or negative number with no decimal places Integer values in JavaScript can range from -90071992654740992(-2 53 ) to 9007199254740992 (2 53 ) A floating-point number contains decimal places or is written using exponential notation
Numeric Data Types Exponential notation , or scientific notation , is a way of writing very large numbers or numbers with many decimal places using shortened format Floating-point values that exceed the largest positive value of + 1.7976931348623157 x 10 308 result in a special value of Infinity

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Boolean Values A Boolean value is a logical value of true or false You can also think of a Boolean value as being yes or no , or on or off . Boolean values are most often used for decision making and comparing data Only the words true and false can be used to indicate Boolean values Boolean values get their name from the 19th century mathematician George Boole
Program That Returns a Boolean Value to an Event Handler

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
LiteralStrings Program
Strings A text string contains zero or more characters surrounded by double or single quotation marks There is no special data type in JavaScript for a single character, such as the char data type in the C, C++, and Java programming languages Take extra care when using single quotations with possessives and contractions in strings JavaScript interpreter always looks for the first closing single or double quotation mark to match an opening single or double quotation mark

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Output of LiteralStrings Program in a Web Browser
Strings An escape character tells the compiler or interpreter that the character that follows it has a special purpose

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern