>> Introduction to JavaScript

Slides:



Advertisements
Similar presentations
JavaScript I. JavaScript is an object oriented programming language used to add interactivity to web pages. Different from Java, even though bears some.
Advertisements

Intro to Javascript CS Client Side Scripting CS380 2.
1 What is JavaScript? JavaScript was designed to add interactivity to HTML pages JavaScript is a scripting language A scripting language is a lightweight.
Introducing JavaScript
The Web Warrior Guide to Web Design Technologies
 2008 Pearson Education, Inc. All rights reserved JavaScript: Introduction to Scripting.
Javascript II Expressions and Data Types. 2 JavaScript Review programs executed by the web browser programs embedded in a web page using the script element.
JavaScript, Third Edition
2012 •••••••••••••••••••••••••••••••••• Summer WorkShop Mostafa Badr
Scripting Languages.
CISC474 - JavaScript 03/02/2011. Some Background… Great JavaScript Guides: –
>> Introduction to JavaScript
Week 9 PHP Cookies and Session Introduction to JavaScript.
2440: 211 Interactive Web Programming Expressions & Operators.
Javascript. Outline Introduction Fundamental of JavaScript Javascript events management DOM and Dynamic HTML (DHTML)
CMPS 211 JavaScript Topic 1 JavaScript Syntax. 2Outline Goals and Objectives Goals and Objectives Chapter Headlines Chapter Headlines Introduction Introduction.
1 JavaScript in Context. Server-Side Programming.
XP Tutorial 10New Perspectives on Creating Web Pages with HTML, XHTML, and XML 1 Working with JavaScript Creating a Programmable Web Page for North Pole.
TUTORIAL 10: PROGRAMMING WITH JAVASCRIPT Session 2: What is JavaScript?
Done by: Hanadi Muhsen1 Tutorial 1.  Learn the history of JavaScript  Create a script element  Write text to a Web page with JavaScript  Understand.
C Derived Languages C is the base upon which many build C++ conventions also influence others *SmallTalk is where most OOP comes Java and Javascript have.
JavaScript Syntax and Semantics. Slide 2 Lecture Overview Core JavaScript Syntax (I will not review every nuance of the language)
CS346 Javascript -3 Module 3 JavaScript Variables.
JavaScript Scripting language What is Scripting ? A scripting language, script language, or extension language is a programming language.
Scott Marino MSMIS Summer Session Web Site Design and Authoring Session 8 Scott Marino.
ECA 225 Applied Interactive Programming1 ECA 225 Applied Online Programming basics.
Internet & World Wide Web How to Program, 5/e © by Pearson Education, Inc. All Rights Reserved.
JavaScript, Fourth Edition
 2008 Pearson Education, Inc. All rights reserved JavaScript: Introduction to Scripting.
1 Server versus Client-Side Programming Server-SideClient-Side.
1 JavaScript in Context. Server-Side Programming.
Java Script About Java Script Document Object Model Incorporating JavaScript Adding JavaScript to HTML Embedding a Javascript External Scripts Javascript.
Open Source Server Side Scripting ECA 236 Open Source Server Side Scripting PHP Basics.
Internet & World Wide Web How to Program, 5/e © by Pearson Education, Inc. All Rights Reserved.
Dr. Abdullah Almutairi Spring PHP is a server scripting language, and a powerful tool for making dynamic and interactive Web pages. PHP is a widely-used,
Introduction to Javascript. What is javascript?  The most popular web scripting language in the world  Used to produce rich thin client web applications.
CGS 3066: Web Programming and Design Spring 2016 Introduction to JavaScript.
Learning Javascript From Mr Saem
JavaScript Tutorial. What is JavaScript JavaScript is the programming language of HTML and the Web Programming makes computers do what you want them to.
1 Agenda  Unit 7: Introduction to Programming Using JavaScript T. Jumana Abu Shmais – AOU - Riyadh.
© 2010 Robert K. Moniot1 Chapter 6 Introduction to JavaScript.
PHP using MySQL Database for Web Development (part II)
>> Fundamental Concepts in PHP
CHAPTER 10 JAVA SCRIPT.
Chapter 6 JavaScript: Introduction to Scripting
Tutorial 10 Programming with JavaScript
Basics of JavaScript Programming Language
Introduction to Scripting
JavaScript Syntax and Semantics
PHP Introduction.
JavaScript.
Week#2 Day#1 Java Script Course
Exercises on JavaScript & Revision
WEB PROGRAMMING JavaScript.
Introduction to JavaScript
PHP.
T. Jumana Abu Shmais – AOU - Riyadh
JavaScript What is JavaScript? What can JavaScript do?
CS105 Introduction to Computer Concepts
HYPERTEXT PREPROCESSOR BY : UMA KAKKAR
JavaScript What is JavaScript? What can JavaScript do?
Tutorial 10: Programming with javascript
Introducing JavaScript
JavaScript: Introduction to Scripting
PHP an introduction.
Web Programming– UFCFB Lecture 13
CIS 136 Building Mobile Apps
Web Programming and Design
CS105 Introduction to Computer Concepts JavaScript
SEEM 4540 Tutorial 4 Basic PHP based on w3Schools
Presentation transcript:

>> Introduction to JavaScript

Separation of Concerns Presentation Styles the Tags Provides Tags (Elements) Structure Functional Modify the Tags Web-based Systems | Misbhauddin

JavaScript - Introduction Client-Side Scripting Language It tells the browser to go do the work Makes Webpages more interactive JavaScript is not the same as Java But has various similarities with the programming language Security Run Script (On Load / Action) Request an HTML webpage HTML Page (w/ Scripts) Rules: JS cannot read/write files from/to the computer file system JS cannot execute any other programs JS cannot establish any connection to other computer, except to download a new HTML page or to send mail Web-Based Systems - Misbhauddin

If No Internet Connection Open the browser (Chrome) On a blank page Right Click on the page and select Inspect Go to the tab for Console Web-Based Systems - Misbhauddin

Web-Based Systems - Misbhauddin Two functions Popups or Alert Boxes alert(“message”) Write function document.write() Like the System.out.println() function in Java Web-Based Systems - Misbhauddin

Web-Based Systems - Misbhauddin Pop-up Boxes in JS ALERT alert("Welcome to the Class"); CONFIRM confirm("Are you sure you want to take IS-311?"); PROMPT prompt("What is XML?", ":("); Returns a value also Web-Based Systems - Misbhauddin

Web-Based Systems - Misbhauddin Variables Variables or Identifiers are named memory locations that hold data to be used throughout the code Syntax value keyword var name = 23; variable name Rules: Case-sensitive Cannot start with a number Can contain letter, numbers & underscore Note: Must be declared before their use in the script var x=23; document.write(x); TRY NOW Web-Based Systems - Misbhauddin

Web-Based Systems - Misbhauddin Types of Variables Numbers: Integers, Decimal Numbers, Negative Numbers Text / String: “Use quotations for values” Boolean: true / false No Value: null (Empty Variable) – Not same as a zero Web-Based Systems - Misbhauddin

Web-Based Systems - Misbhauddin Strings in JavaScript Quotes You can use both ‘single quotes’ and “double quotes” For eg: var str = “This is a sample string”; Escape Characters var x=“I said “Hi” ”; document.write(x); Use backslash (\) to escape Concatenation Use the “+” operator to join two strings var x=“Web”; var y= “Systems”; document.write(x + “ “+y); Web-Based Systems - Misbhauddin

Web-Based Systems - Misbhauddin Strings in JavaScript Pre-defined Functions .length – returns the length of the string .split(a) – splits the string (later in Arrays) .substring(a,b) – extracts the substring between a and b toLowerCase() toUpperCase() Conversion Number to String: Use .toString() function String to Number: Multiply by 1 Ensure that the string has only numbers (0-9) Web-Based Systems - Misbhauddin

Web-Based Systems - Misbhauddin TRY NOW var a = ‘Hello’; var b = ‘World’; document.write(a+” “+b); document.write(“<br\>”); document.write(a.length); document.write(a.substring(2,4)); Web-Based Systems - Misbhauddin

Web-Based Systems - Misbhauddin Operators “+” Addition when both are numbers Concatenation when any is a string Others Minus(-), Multiply(*), Divide(/), Remainder(%) Increment(++), Decrement(--) Assignment (=) Web-Based Systems - Misbhauddin

Conditional Statement SYNTAX keyword If Statement execute some code only if a specific condition is met. Else If Statement Various conditions that are checked one after another until the script finds a true condition Else Statement  If none of the above conditions are met, this block of code is executed. if (something is the case) { more JavaScript commands } Larger than > Smaller than < Larger than or equal to >= Smaller than or equal to <= Equal to == Not equal to != Web-Based Systems - Misbhauddin

Conditional Statement Switch Statement Select one of many blocks of code to be executed SYNTAX The condition for switch can be a “number” or a “string”. switch(test) { case 1: execute code block 1 break; case 2: execute code block 2 default: default code } keywords Web-Based Systems - Misbhauddin

Web-Based Systems - Misbhauddin Boolean Conditions Combine Multiple conditions in the IF statement AND (&&) True when both elements are true OR (||) True when at least one of the elements is true NOT (!) Toggles a statement from true to false or from false to true Web-Based Systems - Misbhauddin

Web-Based Systems - Misbhauddin Looping Statement Initial Value; Test Condition; Update Value For Statement execute some code repeatedly While Statement Convenient when you want to loop until a condition changes Do Statement Useful when you always want to execute the loop at least once SYNTAX keyword for (initialize; condition; update) { more JavaScript commands } Initialize outside do { more JavaScript commands update inside } while (condition); Initialize outside while (condition) { more JavaScript commands update inside } keyword keyword Web-Based Systems - Misbhauddin

Functions in JavaScript SYNTAX keyword Mainly used for event-handling in Web Development Can also be called from other functions (Reuse) function name() { } TRY NOW function test() { alert(“Tested”); } Tip: Make it work by calling the function Web-Based Systems - Misbhauddin

Functions in JavaScript function name(parameters) { return b; } You can use as many parameters as you like Can also return values (numbers, strings, boolean) Use return statement function test(x) { alert(x); } TRY NOW Web-Based Systems - Misbhauddin