String, Math & Miscellaneous Methods & Properties

Slides:



Advertisements
Similar presentations
JavaScript Chapter 7 Working with Strings. String Operations (Chap 2) var colors = red blue; var colors = red blue; var sizes = small large; var sizes.
Advertisements

JavaScript I. JavaScript is an object oriented programming language used to add interactivity to web pages. Different from Java, even though bears some.
And Then There Was JavaScript Chapter 2. The Big Bang JavaScript The Dawn of Man.
Intro to Javascript CS Client Side Scripting CS380 2.
Chapter 4 Methods F Introducing Methods –Benefits of methods, Declaring Methods, and Calling Methods F Passing Parameters –Pass by Value F Overloading.
COP 2800 Lake Sumter State College Mark Wilson, Instructor.
Programming for Artists ART 315 Dr. J. R. Parker Art/Digital Media Lab Lec 13 Fall 2010.
Return values.
1 CS101 Introduction to Computing Lecture 41 Images & Animation (Web Development Lecture 14)
1 CSC 551: Web Programming Spring 2004 client-side programming with JavaScript  scripts vs. programs  JavaScript vs. JScript vs. VBScript  common tasks.
Lesson 4: Formatting Input Data for Arithmetic
Warm-up: Tuesday, March 11  In programming, what is the difference between an object and a class?
Advanced uses of the Mathematics attribute OpendTect Master Class June 15, 2014.
Язык JavaScript Скриптовый язык для выполнения на html-страницах.
6.1 JavaScript Objects and Object- Oriented Programming (OOP)
EGR 105 Foundations of Engineering I Session 3 Excel – Basics through Graphing Fall 2008.
 2004 Prentice Hall, Inc. All rights reserved. Chapter 12 - JavaScript: Objects Outline 12.1 Introduction 12.2 Thinking About Objects 12.3 Math Object.
Introduction to touchdevelop math basic arithmetic operations Disclaimer: This document is provided “as-is”. Information and views expressed in this document,
1 CS101 Introduction to Computing Lecture 38 String Manipulations (Web Development Lecture 13)
1 CS101 Introduction to Computing Lecture 35 Mathematical Methods (Web Development Lecture 12)
Python  By: Ben Blake, Andrew Dzambo, Paul Flanagan.
Scripting Languages.
Test Automation For Web-Based Applications Portnov Computer School Presenter: Ellie Skobel.
1 JavaScript: Objects and Object Models October 25, 2005 Slides modified from Internet & World Wide Web: How to Program (3rd) edition. By Deitel,
String Object.  Conundrum: I would like people to have more time on the revisions…  … but I don't have a lot of time myself for more grading  A1 Revision.
Javascript. Javascript Tools Javascript Console Javascript Console Debugger Debugger DOM Inspector DOM Inspector.
JavaScript For...In Statement The for...in statement loops through the elements of an array or through the properties of an object. Syntax for (variable.
CSE 154 LECTURE 17: JAVASCRIPT. Client-side scripting client-side script: code runs in browser after page is sent back from server often this code manipulates.
Mt. Rushmore, South Dakota CSE 114 – Computer Science I Static Methods andVariables.
1 Math Expressions and Operators. 2 Some C++ Operators Precedence OperatorDescription Higher ( )Function call +Positive - Negative *Multiplication / Division.
ROUND 1 Name a method associated with class String 1.) 15 compareTo() 26 indexOf() 34 length() 2.) 3.) 4.) 3 toUpper() 7 substring() 11 charAt() 5.)
Numbers © Copyright 2014, Fred McClurg All Rights Reserved.
Calculations Chapter 11 Library of math functions, and constants cos, sin, tan, abs, min, max, log, random, sqrt, pow, exp Constants.PI,.E Use care with.
Department of Electrical and Computer Engineering Introduction to C++: Primitive Data Types, Libraries and Operations By Hector M Lugo-Cordero August 27,
Project 1: Using Arrays and Manipulating Strings Essentials for Design JavaScript Level Two Michael Brooks.
Geoff Holmes Date Math Weighted Distr Strings String methods Tokenizers System Examples Utility Classes (Chapter 17) import java.util.*;
© 2007 D. J. Foreman (& U.H. St.Clair) JS-1 More JavaScript for Beginners Basic Concepts.
CSCE 102 – Chapter 11 (Performing Calculations) CSCE General Applications Programming Benito Mendoza Benito Mendoza 1 By Benito Mendoza.
CSE 154 Lecture 6: Javascript.
ICS 3U Math Class. ActionScript 3 – Math Class Rounding ceil – closest integer >= number (rounds up) floor – closest integer
Java Script This is a first JavaScript example. This is a first JavaScript example.
Matlab Tutorial Iman Moazzen First Session – September 11, 2013.
CIS Intro to JAVA Lecture Notes Set 5 26-May-05.
Modern JavaScript Develop And Design Instructor’s Notes Chapter 4 – Simple Variable Types Modern JavaScript Design And Develop Copyright © 2012 by Larry.
 2001 Prentice Hall, Inc. All rights reserved. 1 Chapter 12 - JavaScript: Objects Outline 12.1 Introduction 12.2 Thinking About Objects 12.3 Math Object.
Python I/O Peter Wad Sackett. 2DTU Systems Biology, Technical University of Denmark Classic file reading 1 infile = open(’filename.txt’, ’r’) for line.
CSE 110: Programming Language I Afroza Sultana UB 1230.
Chapter 4 Java Script – Part2. 2 Location object Properties Properties href – whole path will be displayed. ex: window.location.href ( see example 11)
© 2007 D. J. ForemanJS-m1 String, Math & Miscellaneous Methods & Properties.
Java Script: Objects (Chapter 12 in [2]). 2 Outline Introduction Introduction Thinking About Objects Thinking About Objects Math Object Math Object String.
Introduction to JavaScript Pat Morin COMP Outline What is JavaScript? – History – Uses Adding JavaScript to HTML JavaScript syntax JavaScript events.
Some Useful MATLAB Functions
Week 3 - Wednesday CS 121.
Variables and Data Types
Project 9 Creating Pop-up Windows, Adding Scrolling Messages, and Validating Forms.
Programming the Web using XHTML and JavaScript
Working with Text and Numbers in Java
Pertemuan 10 JavaScript.
بسم الله الرّحمن الرّحيم
آموزش مقدماتی نرم افزار MATLAB
Unit 6 part 3 Test Javascript Test.
JavaScript Strings and Arrays
Pertemuan 10 JavaScript.
Python I/O Peter Wad Sackett.
Terminal-Based Programs
មជ្ឈមណ្ឌលកូរ៉េ សហ្វវែរ អេច អ ឌី
Exam Prep.
String, Math & Miscellaneous Methods & Properties
CGS 3066: Web Programming and Design Fall 2019
What We Want To Do User enters: Mary Smith
Presentation transcript:

String, Math & Miscellaneous Methods & Properties © 2006 D. J. Foreman

String Object Methods & Properties anchor( ) big( ) blink( ) bold( ) charAt( ) fontcolor( ) fontsize( ) indexOf( ) italics( ) lastIndexOf( ) link( ) small( ) sub( ) sup( ) substr(start, length) substring(start, end) toLowerCase( ) toUpperCase( ) length is a property of a string - so, no ( ) © 2007 D. J. Foreman

Example: indexOf Purpose: locate a string in another string Let x be a string variable (maybe from some kind of input operation) that currently has the value: "DJ Foreman" We want to see if it contains an "F" J = x.indexOf("F"); J now has the position of the "F" Remember that we start counting at ZERO So J now has the value of 3 © 2007 D. J. Foreman

Example: lastindexOf, length <html> <script language="javascript"> X="DJ Foreman, Ph. D."; document.write(X.lastIndexOf(" ")+"<br>"); document.write(X.length); </script> </html> Result is: 15 17 © 2007 D. J. Foreman

Example of substr Purpose: copy a piece of a string, given its start and length Let X be a string variable (maybe from some kind of input operation) that currently has the value: "DJ Foreman, Ph. D." If we want the "Foreman": M=X.indexOf(" ")+1; // finds the 1st char after the blank N=X.indexOf(","); // finds the comma L=N-M; // computes the length Y=X.substr(M, L); // gets the "Foreman" into Y © 2007 D. J. Foreman

Example of substring Purpose: copy a piece of a string, given its start and ending position Let X be a string variable (maybe from some kind of input operation) that currently has the value: "DJ Foreman, Ph. D." If we want the "Foreman": M=X.indexOf(" ")+1; // finds the 1st char after the blank N=X.indexOf(","); // finds the comma Y=X.substring(M,N); // gets the "Foreman" into Y © 2007 D. J. Foreman

Some Math Object Methods abs( ) ceil( ), floor( ) exp( ) log( ) max( ), min( ) pow( ) random( ) round( ) sqrt( ) sin(radians), asin( ) cos( ), acos( ) tan( ), atan( ) © 2007 D. J. Foreman

Some Math Object Properties LN2, LN10 LN2E, LOG2E PI SQRT2 SQRT1_2 (sqrt of 1/2) ex: Math.PI These are all constants © 2007 D. J. Foreman

Some Misc Methods blur( ) focus( ) select( ) eval( ) parseInt( ) or ParseFloat( ) if var x="10"; y="5"; x+y gives "105" parseInt(x)+parseInt(y) gives 15 © 2007 D. J. Foreman

Some Useful References "Javascript by Example" (various publishers, if you can find it) "How to Set Up and Maintain a WWW Site", Addison Wesley "Essential Javascript for Web Professionals", Prentice Hall "Essential CSS & DHTML for Web Professionals", Prentice Hall © 2007 D. J. Foreman