Presentation is loading. Please wait.

Presentation is loading. Please wait.

A290 TOOLS IN COMPUTING: JAVASCRIPT

Similar presentations


Presentation on theme: "A290 TOOLS IN COMPUTING: JAVASCRIPT"— Presentation transcript:

1 A290 TOOLS IN COMPUTING: JAVASCRIPT
FALL 2017 SECOND 8 WEEKS WELCOME

2 Introduction Instructor: Olgun Sadik Office: Lindley 401D Office Hour: By appointment via Teaching Assistant: Kevin TA Office Hour: Second floor of Lindley Hall from 2:30 - 3:30 on Mondays

3 Course Pre-survey Please fill out the course pre-survey from the class website schedule page.

4 Course Resources Class Website Canvas Syllabus
Access to Course Materials (Books 24/7) Course Schedule Canvas Assignments/Feedback Announcements Grades Lets go over those…

5 JavaScript  JavaScript was introduced in 1995 as a way to add programs to web pages in the Netscape Navigator browser. Nothing to do with the programming language named Java. JavaScript is flexible in what it allows and good for beginners. JS is a client side scripting language.  JavaScript was introduced in 1995 as a way to add programs to web pages in the Netscape Navigator browser.  It is important to note that JavaScript has almost nothing to do with the programming language named Java.  The similar name was inspired by marketing considerations, rather than good judgment.  JavaScript is ridiculously liberal in what it allows.  The idea behind this design was that it would make programming in JavaScript easier for beginners. In actuality, it mostly makes finding problems in your programs harder because the system will not point them out to you.

6 Today’s class Variables Data Types in JavaScript
Number String (text) Boolean Undefined Null Some operators in JavaScript Constants Comments in JavaScript

7 Variables

8 Variables We can't do much in the way of programs or scripts unless we have a way to store values. They are containers and their values (ingredients) change based on programmers’ needs. Variables in programming store values such as numbers, text and others…

9 Variables The general idea of a variable is that you pick a variable name and assign it a value After that, you can just use the name of the variable any time you want to use that value  These words "name", "value", and "assign" have specific technical meaning

10 Variables in JS JavaScript is a loosely-typed language. it sees a variable as a box that can hold any type of data at any given time. That box may grow or shrink to accommodate the data you put into it, but it does not discriminate between what types of data can fit in the box. This means that a variable can contain a text value at one time, and a number value at another Defining a variable in JavaScript requires the use of a variable declaration statement and ends with a semicolon var myVariable; The var keyword is used specifically for declaring variables JavaScript is a case-sensitive language myVariable has been declared, but it has not been initialized or assigned a value. To assign data to a variable, use the equals sign (=), also known as the assignment operator, to assign a value to the variable. An operator is a symbol or keyword that takes one or more operands as input and performs an action on those operands. myVariable = "some text"; // initialization statement

11 Variables in JS A variable's value can be overwritten with another value at any time myVariable = 100; A variable can also be assigned the value contained in another variable var myVariable2 = myVariable;

12 Data Types in JavaScript
A data type is a type of value represented in a programming language, such as numbers, text, and true/false values JavaScript has five primitive data types. They are: Number String (text) Boolean Undefined Null JavaScript is different from most other languages in that it does not distinguish between different types of numbers, such as integer and decimal numbers. Instead, all numbers are represented by the Number type, which consists solely of floating-point numbers, rational numbers with a very large value range JavaScript uses a fixed number of bits, namely 64 of them, to store a single number value. There are only so many patterns you can make with 64 bits, which means that the amount of different numbers that can be represented is limited.

13 Arithmetic Operators + Addition Adds the operands together −
Subtraction Subtracts the right operand from the left operand * Multiplication Multiplies the operands together / Division Divides the left operand by the right operand % Modulus Divides the left operand by the right operand and returns the remainder of the operation

14 Small Activity What is the final value of myNumber?
var myNumber = 2 + 2; myNumber = myNumber - 4; myNumber = * / 2; myNumber = (1 + 2) * / 2;

15 Strings Strings are text values—sequences of zero or more characters. Strings are delimited by double-quote (“) or single-quote characters (’). var str1 = "Hello, World"; var str2 = 'Hello, Indiana'; Unlike other languages, JavaScript does not discriminate between the type of quotes used to delimit strings. Using single quotes does not change how JavaScript treats the string compared to using double quotes. They're all the same,

16 Concatenation Operator
Concatenating two or more strings requires the use of the concatenation operator: the plus sign (+). The following code concatenates the original string value in str1 with another string value to modify the data contained within str1: str1= ”This is a ”; str2=“string”; str1=str1+str2; //The value of str2 is concenated within str1

17 Constants In JavaScript, constants are declared with const keyword and assigned at the time of the declaration. const COUNTRY= ‘Turkey';

18 Comments var str1 = "Hello, World"; //assigns “Hello, World” to string variable str1

19 JS in Action See example1.html and example1.js

20 Before the next class No class on Thursday. You need to read chapter 2 from the text book “Eloquent JavaScript: A Modern Introduction to Programming, 2nd Edition ” Then, you need to review the week 1_class2 presentation that I provided in the class website. You have your assignment questions hidden in that PPT. You need to carefully read the slides and review the examples to find your assignment questions.


Download ppt "A290 TOOLS IN COMPUTING: JAVASCRIPT"

Similar presentations


Ads by Google