- JavaScript was created in 1995 by Brandon Eich and was originally called LiveScript. It was renamed to JavaScript to capitalize on the popularity of Java, though the two languages are unrelated.
- JavaScript is an interpreted, prototype-based scripting language that is commonly used for client-side web development but can also be used for server-side applications and other programs. It has dynamic typing and supports functions as first-class objects.
- The document discusses JavaScript syntax including variables, numbers, strings, comments, control flow statements like if/else and loops, and functions. It also covers the Rhino runtime environment for running JavaScript without a browser.
This document provides an overview of JavaScript, including its uses, syntax, data types, operators, and objects. JavaScript is an object-based scripting language used to program the behavior of web pages. It allows for client-side validation, dynamic drop-down menus, displaying data and time, and other interactive effects. JavaScript code can be embedded directly in HTML using <script> tags or linked externally. The core data types include numbers, strings, Booleans, arrays, and objects. Objects are similar to arrays but use named indexes instead of numbered indexes. Key JavaScript concepts covered include variables, literals, functions, conditionals, and more.
The document discusses the history and evolution of JavaScript, including its origins from Java and LiveScript, standardization as ECMAScript, and key features such as dynamic typing, objects, functions, and prototypal inheritance. It also covers JavaScript data types like numbers, strings, Booleans, objects, and functions, and how the language handles values, scope, operators, and other elements.
The document discusses challenges in implementing a dynamic language like JavaScript on the Java Virtual Machine (JVM). Some key points:
- Nashorn is a JavaScript runtime written in Java that generates JVM bytecode, aiming to be 2-10x faster than previous solutions like Rhino.
- Compiling JavaScript to JVM bytecode is difficult as JavaScript has dynamic types, runtime changes, and number representations that don't map cleanly to Java's static types.
- Nashorn uses static analysis to infer types where possible and optimize for primitive number representations, but this only goes so far with JavaScript's dynamic nature.
- As JavaScript code changes, Nashorn may need to transition to more dynamic, adaptive and optimistic techniques
Introduction to web programming for java and c# programmers by @drpicoxDavid Rodenas
(better presented by @drpicox)
Slides of an introductory course for web programming focusing in basic Javascript and CSS concepts. It assumes knowledge of programming, Java or C#.
A great intro to JavaScript. Covers all the basics you need to get up and running with Ajax development. http://www.enterpriseajax.com
This document provides an agenda and overview for a two-day JavaScript foundations training course taught by Troy Miles. Day one covers JavaScript fundamentals like variables, data types, operators, and functions. It also covers controlling program flow and object-oriented programming. Day two covers working with objects and JSON, functional programming, good coding practices, and an overview of ECMAScript 2015 features. The document provides tips for participants to follow along, do exercises, and ask questions. It also includes summaries of key JavaScript concepts to be covered each day like the global object, equality operators, and string and date object methods.
JavaScript was originally created as LiveScript in 1995 and renamed to JavaScript. It is an interpreted scripting language that can be added to HTML pages to provide dynamic interactivity. JavaScript code is executed by the browser's JavaScript engine and does not need to be compiled. It allows manipulating the structure, style, and content of HTML documents, validating form data, detecting browser capabilities, and much more.
The document provides an overview of key JavaScript data types and concepts including:
- Primitive data types like numbers, strings, booleans, objects, functions, arrays, dates, regular expressions, and special values like NaN and undefined.
- How numbers are stored as floats and to be careful of precision issues. The Math object can be used for advanced math.
- Strings can represent character sequences and have useful methods.
- Objects are collections of key-value pairs that can contain other objects. Arrays are object that are for storing lists of values.
- Functions are objects that can take parameters and return values. Functions have access to an arguments object.
Kotlin is a programming language that can be used for Android development. It is interoperable with Java and compiles to JVM bytecode. Some key features of Kotlin discussed in the document include null safety, properties, functions, classes, inheritance, and Android integration. Kotlin code can inherit from and call Java code, and most Android APIs are written in Java so they can be called from Kotlin as well. The document provides examples of Kotlin syntax for variables, control flow, collections, and comparing Kotlin and Java implementations of common patterns like fragments. References are also included for further Kotlin learning resources.
Introduction to Ruby with accompanying code at https://github.com/heatherjc07/RubyIntroduction. Covers flow control, methods, classes and types
JavaScript - Chapter 4 - Types and StatementsWebStackAcademy
A computer program is a list of "instructions" to be "executed" by a computer.
In a programming language, these programming instructions are called statements.
A JavaScript program is a list of programming statements.
JavaScript statements are composed of:
Values, Operators, Expressions, Keywords, and Comments.
This statement tells the browser to write "Hello Dolly." inside an HTML element with id="demo":
JavaScript Data Types
JavaScript variables can hold many data types: numbers, strings, objects and more.
In programming, data types is an important concept.
To be able to operate on variables, it is important to know something about the type.
Game Design and Development Workshop Day 1Troy Miles
This course teaches you how to build awesome video games using Cocos2Dx. Cocos2Dx is a feature packed, free game development engine. It is cross platform, high performance, and supports three languages: C++, Lua and JavaScript. With it, you can write games for iOS, Android, Windows, Mac, and the Web. It is nothing short of amazing and this course teaches you how to use it. We will program Cocos2Dx in JavaScript, but this is not a programming class. If you don't know how to write code in JavaScript or some other curly brace language, this is not the course for you. For those whose JavaScript is rusty, we will do quick language overview. Don't let the JavaScript part fool you. Cocos2Dx is built from highly optimized C++ and OpenGL, JavaScript is used for game logic, not graphics. Our games will run at a super fast, 60 frames a second.
This document provides an overview of the JavaScript programming language, including its history, key concepts, values, objects, and functions. It summarizes JavaScript as a dynamic language that unifies objects and functions, uses prototype-based inheritance, and loosely typed values. Everything in JavaScript is an object, which can be used to represent records, trees, and other data structures using dynamic object literals.
Unit I Advanced Java Programming Courseparveen837153
This document provides information about an Advanced Java Programming course taught by Dr. S.SHAIK PARVEEN. It includes details about the course such as prerequisites, objectives, units, and basic Java syntax concepts covered. The document outlines topics like variable declarations, operators, control flow statements, arrays, and object-oriented programming concepts in Java. It aims to teach students advanced Java programming skills like implementing object-oriented principles, working with classes, methods, and threads, as well as creating applets, GUI components, and Java beans.
The document provides an overview of topics to be covered in a Javascript session, including: data types, arithmetic operators, conditional statements, loops, functions, arrays, objects, and JSON. It then covers each topic in more detail with examples and explanations of key concepts like declaring and initializing variables, variable scope, assignment operators, if/else statements, boolean logic, for/while loops, functions with parameters and return values, arrays with different data types and array methods, and objects with properties that can be accessed and assigned values.
This document provides an overview of key Java concepts including:
- Java is an object-oriented, platform-independent programming language similar to C++ in syntax. It was developed by Sun Microsystems.
- Java features include automatic memory management, type safety, multi-threading, and network programming capabilities. Code is compiled to bytecode that runs on the Java Virtual Machine.
- Core Java concepts discussed include primitive types, variables, operators, control flow statements, methods, classes, objects, arrays, inheritance, polymorphism and encapsulation.
- Additional topics covered are packages, access modifiers, constructors, overloading, overriding, and inner classes.
The document outlines the topics covered in an advanced Java programming course, including object-oriented programming concepts, Java programming fundamentals, GUI programming, networking, and server-side programming. It also provides examples of Java code demonstrating basic syntax, methods, classes, strings, and math functions.
BCS SPA 2010 - An Introduction to Scala for Java DevelopersMiles Sabin
This document provides an introduction to Scala for Java developers. It outlines how Scala cleans up Java syntax by making semi-colons optional, using == for equals and eq for reference equality, and allowing periods to be omitted. It also describes how Scala goes beyond Java by supporting features like case classes, pattern matching, named and default arguments, and mixin composition with traits. The document provides examples of using these features and explains how Scala seamlessly interoperates with Java.
An Introduction to Scala for Java DevelopersMiles Sabin
The document provides an introduction to Scala for Java developers. It outlines key features of Scala including cleaning up Java syntax, going beyond Java with features like case classes, traits, and pattern matching, and its functional focus including support for higher-order functions, the Option type, and for comprehensions. The document also briefly discusses the Scala IDE for Eclipse.
This document provides an introduction to JavaScript, including what JavaScript is used for, how it interacts with HTML and CSS, and some basic JavaScript concepts. JavaScript allows making web pages interactive by inserting dynamic text, reacting to events like clicks, performing calculations, and getting information about the user's computer. It is commonly used for calculations, waiting for and responding to events, and manipulating HTML tags. The document discusses JavaScript's role on the client-side, using variables, data types, operators, arrays, functions, and the console for debugging. It provides examples of declaring variables, strings, logical operators, arrays, and functions.
This document provides information on JavaScript terms and rules to remember for reading in user input and displaying output. It includes definitions of terms like alert(), prompt(), parseFloat(), and document.write(). It also provides code examples of using parseFloat() and document.write() to display numeric values. Finally, it includes exercises asking the reader to write JavaScript code to calculate work done and density, as well as to prompt for and display user data.
This document provides concepts to memorize for the Oracle Certificate Associate Java 7 exam. It includes summaries of topics like default constructors, legal vs illegal class declarations, interfaces, methods, numbers, floating point numbers, boxing and unboxing, literals, operators, strings, arrays, collections, loops, and common mistakes. The document is from a personal note and is not an official Java course, but rather concepts to commit to memory for the exam. It cites three books as references for additional study material.
The Evolution of Async-Programming (SD 2.0, JavaScript)jeffz
This document discusses the evolution of asynchronous programming. It begins by explaining why asynchronous programming is important for cloud, web and mobile applications due to their inherently asynchronous nature. It then covers several approaches to asynchronous programming including callback-based, iterator-based, library-based using reactive frameworks, and language-based features. Specific examples are provided for each approach. The document concludes by discussing some future directions for asynchronous programming support in languages like C#.
This document provides an overview of JavaScript basics including data types, dynamic typing, strings, numbers, Booleans, arrays, objects, functions, scope, and common patterns like namespaces, modules, and immediately invoked function expressions (IIFEs). It covers topics like primitive vs reference types, type coercion, equality operators, object literals, constructors, and the revealing module pattern for encapsulating code.
This document provides an agenda and overview for a two-day JavaScript foundations training course taught by Troy Miles. Day one covers JavaScript fundamentals like variables, data types, operators, and functions. It also covers controlling program flow and object-oriented programming. Day two covers working with objects and JSON, functional programming, good coding practices, and an overview of ECMAScript 2015 features. The document provides tips for participants to follow along, do exercises, and ask questions. It also includes summaries of key JavaScript concepts to be covered each day like the global object, equality operators, and string and date object methods.
JavaScript was originally created as LiveScript in 1995 and renamed to JavaScript. It is an interpreted scripting language that can be added to HTML pages to provide dynamic interactivity. JavaScript code is executed by the browser's JavaScript engine and does not need to be compiled. It allows manipulating the structure, style, and content of HTML documents, validating form data, detecting browser capabilities, and much more.
The document provides an overview of key JavaScript data types and concepts including:
- Primitive data types like numbers, strings, booleans, objects, functions, arrays, dates, regular expressions, and special values like NaN and undefined.
- How numbers are stored as floats and to be careful of precision issues. The Math object can be used for advanced math.
- Strings can represent character sequences and have useful methods.
- Objects are collections of key-value pairs that can contain other objects. Arrays are object that are for storing lists of values.
- Functions are objects that can take parameters and return values. Functions have access to an arguments object.
Kotlin is a programming language that can be used for Android development. It is interoperable with Java and compiles to JVM bytecode. Some key features of Kotlin discussed in the document include null safety, properties, functions, classes, inheritance, and Android integration. Kotlin code can inherit from and call Java code, and most Android APIs are written in Java so they can be called from Kotlin as well. The document provides examples of Kotlin syntax for variables, control flow, collections, and comparing Kotlin and Java implementations of common patterns like fragments. References are also included for further Kotlin learning resources.
Introduction to Ruby with accompanying code at https://github.com/heatherjc07/RubyIntroduction. Covers flow control, methods, classes and types
JavaScript - Chapter 4 - Types and StatementsWebStackAcademy
A computer program is a list of "instructions" to be "executed" by a computer.
In a programming language, these programming instructions are called statements.
A JavaScript program is a list of programming statements.
JavaScript statements are composed of:
Values, Operators, Expressions, Keywords, and Comments.
This statement tells the browser to write "Hello Dolly." inside an HTML element with id="demo":
JavaScript Data Types
JavaScript variables can hold many data types: numbers, strings, objects and more.
In programming, data types is an important concept.
To be able to operate on variables, it is important to know something about the type.
Game Design and Development Workshop Day 1Troy Miles
This course teaches you how to build awesome video games using Cocos2Dx. Cocos2Dx is a feature packed, free game development engine. It is cross platform, high performance, and supports three languages: C++, Lua and JavaScript. With it, you can write games for iOS, Android, Windows, Mac, and the Web. It is nothing short of amazing and this course teaches you how to use it. We will program Cocos2Dx in JavaScript, but this is not a programming class. If you don't know how to write code in JavaScript or some other curly brace language, this is not the course for you. For those whose JavaScript is rusty, we will do quick language overview. Don't let the JavaScript part fool you. Cocos2Dx is built from highly optimized C++ and OpenGL, JavaScript is used for game logic, not graphics. Our games will run at a super fast, 60 frames a second.
This document provides an overview of the JavaScript programming language, including its history, key concepts, values, objects, and functions. It summarizes JavaScript as a dynamic language that unifies objects and functions, uses prototype-based inheritance, and loosely typed values. Everything in JavaScript is an object, which can be used to represent records, trees, and other data structures using dynamic object literals.
Unit I Advanced Java Programming Courseparveen837153
This document provides information about an Advanced Java Programming course taught by Dr. S.SHAIK PARVEEN. It includes details about the course such as prerequisites, objectives, units, and basic Java syntax concepts covered. The document outlines topics like variable declarations, operators, control flow statements, arrays, and object-oriented programming concepts in Java. It aims to teach students advanced Java programming skills like implementing object-oriented principles, working with classes, methods, and threads, as well as creating applets, GUI components, and Java beans.
The document provides an overview of topics to be covered in a Javascript session, including: data types, arithmetic operators, conditional statements, loops, functions, arrays, objects, and JSON. It then covers each topic in more detail with examples and explanations of key concepts like declaring and initializing variables, variable scope, assignment operators, if/else statements, boolean logic, for/while loops, functions with parameters and return values, arrays with different data types and array methods, and objects with properties that can be accessed and assigned values.
This document provides an overview of key Java concepts including:
- Java is an object-oriented, platform-independent programming language similar to C++ in syntax. It was developed by Sun Microsystems.
- Java features include automatic memory management, type safety, multi-threading, and network programming capabilities. Code is compiled to bytecode that runs on the Java Virtual Machine.
- Core Java concepts discussed include primitive types, variables, operators, control flow statements, methods, classes, objects, arrays, inheritance, polymorphism and encapsulation.
- Additional topics covered are packages, access modifiers, constructors, overloading, overriding, and inner classes.
The document outlines the topics covered in an advanced Java programming course, including object-oriented programming concepts, Java programming fundamentals, GUI programming, networking, and server-side programming. It also provides examples of Java code demonstrating basic syntax, methods, classes, strings, and math functions.
BCS SPA 2010 - An Introduction to Scala for Java DevelopersMiles Sabin
This document provides an introduction to Scala for Java developers. It outlines how Scala cleans up Java syntax by making semi-colons optional, using == for equals and eq for reference equality, and allowing periods to be omitted. It also describes how Scala goes beyond Java by supporting features like case classes, pattern matching, named and default arguments, and mixin composition with traits. The document provides examples of using these features and explains how Scala seamlessly interoperates with Java.
An Introduction to Scala for Java DevelopersMiles Sabin
The document provides an introduction to Scala for Java developers. It outlines key features of Scala including cleaning up Java syntax, going beyond Java with features like case classes, traits, and pattern matching, and its functional focus including support for higher-order functions, the Option type, and for comprehensions. The document also briefly discusses the Scala IDE for Eclipse.
This document provides an introduction to JavaScript, including what JavaScript is used for, how it interacts with HTML and CSS, and some basic JavaScript concepts. JavaScript allows making web pages interactive by inserting dynamic text, reacting to events like clicks, performing calculations, and getting information about the user's computer. It is commonly used for calculations, waiting for and responding to events, and manipulating HTML tags. The document discusses JavaScript's role on the client-side, using variables, data types, operators, arrays, functions, and the console for debugging. It provides examples of declaring variables, strings, logical operators, arrays, and functions.
This document provides information on JavaScript terms and rules to remember for reading in user input and displaying output. It includes definitions of terms like alert(), prompt(), parseFloat(), and document.write(). It also provides code examples of using parseFloat() and document.write() to display numeric values. Finally, it includes exercises asking the reader to write JavaScript code to calculate work done and density, as well as to prompt for and display user data.
This document provides concepts to memorize for the Oracle Certificate Associate Java 7 exam. It includes summaries of topics like default constructors, legal vs illegal class declarations, interfaces, methods, numbers, floating point numbers, boxing and unboxing, literals, operators, strings, arrays, collections, loops, and common mistakes. The document is from a personal note and is not an official Java course, but rather concepts to commit to memory for the exam. It cites three books as references for additional study material.
The Evolution of Async-Programming (SD 2.0, JavaScript)jeffz
This document discusses the evolution of asynchronous programming. It begins by explaining why asynchronous programming is important for cloud, web and mobile applications due to their inherently asynchronous nature. It then covers several approaches to asynchronous programming including callback-based, iterator-based, library-based using reactive frameworks, and language-based features. Specific examples are provided for each approach. The document concludes by discussing some future directions for asynchronous programming support in languages like C#.
This document provides an overview of JavaScript basics including data types, dynamic typing, strings, numbers, Booleans, arrays, objects, functions, scope, and common patterns like namespaces, modules, and immediately invoked function expressions (IIFEs). It covers topics like primitive vs reference types, type coercion, equality operators, object literals, constructors, and the revealing module pattern for encapsulating code.
How to Manage & Create a New Department in Odoo 18 EmployeeCeline George
In Odoo 18's Employee module, organizing your workforce into departments enhances management and reporting efficiency. Departments are a crucial organizational unit within the Employee module.
This presentation was provided by Jennifer Gibson of Dryad, during the first session of our 2025 NISO training series "Secrets to Changing Behavior in Scholarly Communications." Session One was held June 5, 2025.
Energy Balances Of Oecd Countries 2011 Iea Statistics 1st Edition Oecdrazelitouali
Energy Balances Of Oecd Countries 2011 Iea Statistics 1st Edition Oecd
Energy Balances Of Oecd Countries 2011 Iea Statistics 1st Edition Oecd
Energy Balances Of Oecd Countries 2011 Iea Statistics 1st Edition Oecd
How to Create Quotation Templates Sequence in Odoo 18 SalesCeline George
In this slide, we’ll discuss on how to create quotation templates sequence in Odoo 18 Sales. Odoo 18 Sales offers a variety of quotation templates that can be used to create different types of sales documents.
Unit- 4 Biostatistics & Research Methodology.pdfKRUTIKA CHANNE
Blocking and confounding (when a third variable, or confounder, influences both the exposure and the outcome) system for Two-level factorials (a type of experimental design where each factor (independent variable) is investigated at only two levels, typically denoted as "high" and "low" or "+1" and "-1")
Regression modeling (statistical model that estimates the relationship between one dependent variable and one or more independent variables using a line): Hypothesis testing in Simple and Multiple regression models
Introduction to Practical components of Industrial and Clinical Trials Problems: Statistical Analysis Using Excel, SPSS, MINITAB®️, DESIGN OF EXPERIMENTS, R - Online Statistical Software to Industrial and Clinical trial approach
How to Manage Maintenance Request in Odoo 18Celine George
Efficient maintenance management is crucial for keeping equipment and work centers running smoothly in any business. Odoo 18 provides a Maintenance module that helps track, schedule, and manage maintenance requests efficiently.
Artificial intelligence Presented by JM.jmansha170
AI (Artificial Intelligence) :
"AI is the ability of machines to mimic human intelligence, such as learning, decision-making, and problem-solving."
Important Points about AI:
1. Learning – AI can learn from data (Machine Learning).
2. Automation – It helps automate repetitive tasks.
3. Decision Making – AI can analyze and make decisions faster than humans.
4. Natural Language Processing (NLP) – AI can understand and generate human language.
5. Vision & Recognition – AI can recognize images, faces, and patterns.
6. Used In – Healthcare, finance, robotics, education, and more.
Owner By:
Name : Junaid Mansha
Work : Web Developer and Graphics Designer
Contact us : +92 322 2291672
Email : [email protected]
A short update and next week. I am writing both Session 9 and Orientation S1.
As a Guest Student,
You are now upgraded to Grad Level.
See Uploads for “Student Checkin” & “S8”. Thx.
Thank you for attending our workshops.
If you are new, do welcome.
Grad Students: I am planning a Reiki-Yoga Master Course (As a package). I’m Fusing both together.
This will include the foundation of each practice. Our Free Workshops can be used with any Reiki Yoga training package. Traditional Reiki does host rules and ethics. Its silent and within the JP Culture/Area/Training/Word of Mouth. It allows remote healing but there’s limits As practitioners and masters. We are not allowed to share certain secrets/tools. Some content is designed only for “Masters”. Some yoga are similar like the Kriya Yoga-Church (Vowed Lessons). We will review both Reiki and Yoga (Master tools) in the Course upcoming.
Session Practice, For Reference:
Before starting a session, Make sure to check your environment. Nothing stressful. Later, You can decorate a space as well.
Check the comfort level, any needed resources (Yoga/Reiki/Spa Props), or Meditation Asst?
Props can be oils, sage, incense, candles, crystals, pillows, blankets, yoga mat, any theme applies.
Select your comfort Pose. This can be standing, sitting, laying down, or a combination.
Monitor your breath. You can add exercises.
Add any mantras or affirmations. This does aid mind and spirit. It helps you to focus.
Also you can set intentions using a candle.
The Yoga-key is balancing mind, body, and spirit.
Finally, The Duration can be long or short.
Its a good session base for any style.
Next Week’s Focus:
A continuation of Intuition Development. We will review the Chakra System - Our temple. A misguided, misused situation lol. This will also serve Attunement later.
For Sponsor,
General updates,
& Donations:
Please visit:
https://ldmchapels.weebly.com
HOW YOU DOIN'?
Cool, cool, cool...
Because that's what she said after THE QUIZ CLUB OF PSGCAS' TV SHOW quiz.
Grab your popcorn and be seated.
QM: THARUN S A
BCom Accounting and Finance (2023-26)
THE QUIZ CLUB OF PSGCAS.
Different pricelists for different shops in odoo Point of Sale in Odoo 17Celine George
Price lists are a useful tool for managing the costs of your goods and services. This can assist you in working with other businesses effectively and maximizing your revenues. Additionally, you can provide your customers discounts by using price lists.
Analysis of Quantitative Data Parametric and non-parametric tests.pptxShrutidhara2
This presentation covers the following points--
Parametric Tests
• Testing the Significance of the Difference between Means
• Analysis of Variance (ANOVA) - One way and Two way
• Analysis of Co-variance (One-way)
Non-Parametric Tests:
• Chi-Square test
• Sign test
• Median test
• Sum of Rank test
• Mann-Whitney U-test
Moreover, it includes a comparison of parametric and non-parametric tests, a comparison of one-way ANOVA, two-way ANOVA, and one-way ANCOVA.
Human Anatomy and Physiology II Unit 3 B pharm Sem 2
Respiratory system
Anatomy of respiratory system with special reference to anatomy
of lungs, mechanism of respiration, regulation of respiration
Lung Volumes and capacities transport of respiratory gases,
artificial respiration, and resuscitation methods
Urinary system
Anatomy of urinary tract with special reference to anatomy of
kidney and nephrons, functions of kidney and urinary tract,
physiology of urine formation, micturition reflex and role of
kidneys in acid base balance, role of RAS in kidney and
disorders of kidney
3. 3
What is JavaScript?
• created in 1995 by Brandon Eich of Netscape/Mozilla
"JS had to "look like Java" only less so, be Java’s dumb kid brother or
boy-hostage sidekick. Plus, I had to be done in ten days or something
worse than JS would have happened." - Brandon Eich
originally called "LiveScript" to match Netscape branding
renamed to JavaScript to capitalize on popularity of Java
submitted as a standard to ECMA in 1997 as "ECMAScript"
• not directly related to Java
Eich claims he was most influenced by Self and Scheme
some JS syntax, libraries, etc. are ripped off by Java, C
D. Crockford: "JavaScript is Lisp in C's clothing."
4. 4
JavaScript today
• possibly the most used programming language today (!!)
mostly used for client-side web page scripting, but
increasingly used to build server apps, other programs
current standardized version: ECMAScript 5 (2009)
• Is JavaScript a bad programming language??
had bad browser behavior, slow, poor web coders, etc.
recent implementations are faster, better, more stable
JS in browser works with "DOM" (Document Object Model)
related JS+web technologies: Ajax, JSON, jQuery, etc.
spin-off languages: JScript (MS), ActionScript (Adobe), etc.
5. 5
JavaScript vs. Java
• interpreted, not compiled
dynamic typing
first-class functions; nested functions; closures
a structured, imperative object-oriented, scripting lang.
prototype-based object and inheritance system
sophisticated first-class resizable array type
first-class regular expression support
• more relaxed syntax and rules
fewer and "looser" data types
variables don't always need to be declared
key construct is first-class function rather than the class
+ = JavaScript
6. 6
Running JS code in a browser
<html>
<head>
<script src="myfile.js"
type="text/javascript"></script>
</head>
<body>
<p>My web page</p> ...
</body>
</html>
We won't be doing this!
– aside: Firebug extension
7. 7
Running JS without a browser
• CommonJS: project started in 2009 to create a standard
library of JS types and functions for all non-web apps
Rhino (Mozilla)
V8 (Google / Chrome)
Narwhal
others: Ringo, Joyent, Sprout, Persevere
• We support the Rhino runtime for this course.
http://www.mozilla.org/rhino/
java -jar rhino.jar JSFileName
10. 10
print (CommonJS)
print(expr, expr, ..., expr);
• provided by Rhino as part of CommonJS
print("Hello, world!n");
print(1+1, 4, 3*2); // 2 4 6
other shell variables/functions:
– arguments, environment, help, defineClass,
deserialize, load(filename), loadClass,
readFile(name), readURL, runCommand, seal,
serialize, spawn, sync, quit, version
doesn't work in web browsers (use alert instead)
11. 11
Variables
var name = expression;
• Examples:
var age = 32;
var weight = 127.4;
var clientName = "Connie Client";
• variables are declared with var keyword (case sensitive)
• types not specified, but JS does have types
Number, Boolean, String, Array, Object,
Function, Null, Undefined
can find out a variable's type by calling typeof
12. 12
Numbers
var enrollment = 99;
var medianGrade = 2.8;
var credits = 5 + 4 + (2 * 3);
• integers and real numbers are the same type
(no int vs. double)
• same operators: + - * / % ++ -- = += -= *= /= %=
similar precedence to Java
many operators auto-convert types: "2" * 3 is 6
13. 13
Number properties/methods
Number object "static" properties
Number.MAX_VALUE largest possible number, roughly 10308
Number.MIN_VALUE smallest positive number, roughly 10-324
Number.NaN Not-a-Number; result of invalid computations
Number.POSITIVE_INFINIT
Y
infinity; result of 1/0
Number.NEGATIVE_INFINIT
Y
negative infinity; result of -1/0
Number instance methods
.toString([base]) convert a number to a string with optional base
.toFixed(digits) fixed-point real with given # digits past decimal
.toExponential(digits) convert a number to scientific notation
.toPrecision(digits) floating-point real, given # digits past decimal
global methods related to numbers
isNaN(expr) true if the expression evaluates to NaN
isFinite(expr) true if expr is neither NaN nor an infinity
14. 14
The Math object
var rand1to10 = Math.floor(Math.random() * 10 +
1);
var three = Math.floor(Math.PI);
• Math methods: abs, ceil, cos, floor, log, max,
min, pow, random, round, sin, sqrt, tan
• properties: E, PI
15. 15
Math properties/methods
Math.E e, base of natural logarithms: 2.718...
Math.LN10, Math.LN2,
Math.LOG2E, Math.LOG10E
natural logarithm of 10 and 2;
logarithm of e in base 2 and base 10
Math.PI , circle's circumference/diameter: 3.14159...
Math.SQRT1_2, Math.SQRT2 square roots of 1
/2 and 2
Math.abs(n) absolute value
Math.acos/asin/atan(n) arc-sin/cosine/tangent of angle in radians
Math.ceil(n) ceiling (rounds a real number up)
Math.cos/sin/tan(n) sin/cosine/tangent of angle in radians
Math.exp(n) en
, e raised to the nth power
Math.floor(n) floor (rounds a real number down)
Math.log(n) natural logarithm (base e)
Math.max/min(a, b...) largest/smallest of 2 or more numbers
Math.pow(x, y) xy
, x raised to the yth power
Math.random() random real number k in range 0 ≤ k < 1
Math.round(n) round number to nearest whole number
Math.sqrt(n) square root
17. 17
Strings
var s = "Connie Client";
var firstName = s.substring(0, s.indexOf(" "));
var len = s.length; // 13
var s2 = 'Melvin Merchant'; // can use "" or ''
• String methods: charAt, charCodeAt,
fromCharCode, indexOf, lastIndexOf, replace,
split, substring, toLowerCase, toUpperCase
charAt returns a one-letter string (there is no char type)
length is a property (not a method as in Java)
• concatenation with + : 1 + 1 is 2, but "1" + 1 is "11"
• strings can be compared with <, <=, ==, !=, >, >=
18. 18
String methods
String.fromCharCode(exp
r)
converts ASCII integer → String
.charAt(index) returns character at index, as a String
.charCodeAt(index) returns ASCII value at a given index
.concat(str...) returns concatenation of string(s) to this one
.indexOf(str[,start])
.lastIndexOf(str[,start
])
first/last index at which given string begins in
this string, optionally starting from given index
.match(regexp) returns any matches for this string against the
given string or regular expression ("regex")
.replace(old, new) replaces first occurrence of old string or regular
expr. with new string (use regex to replace all)
.search(regexp) first index where given regex occurs
.slice(start, end)
.substring(start, end)
substr. from start (inclusive) to end (exclusive)
.split(delimiter[,limit
])
break apart a string into an array of strings
19. 19
More about Strings and numbers
• escape sequences behave as in Java: ' " & n t
• convert string to number with parseInt, parseFloat:
var count = 10;
var s1 = "" + count; // "10"
var s2 = count + " bananas, ah ah ah!";
var n1 = parseInt("42 is the answer"); // 42
var n2 = parseInt("0x2A", 16); // 42
var n3 = parseFloat("3.1415"); // 3.1415
var bad = parseInt("booyah"); // NaN
• access the letters of a String with [] or charAt:
var firstLetter = s[0];
var firstLetter = s.charAt(0);
var lastLetter = s.charAt(s.length - 1);
20. 20
The for loop (same as Java)
for (initialization; test; update) {
statements;
}
for (var i = 0; i < 10; i++) {
print(i + "n");
}
var s1 = "hi, there!!!", s2 = "";
for (var i = 0; i < s1.length; i++) {
var c = s1.charAt(i);
if (c >= "a" && c <= "z") {
s2 += c + c;
}
}
// s2 stores "hhiitthheerree"
21. 21
Logical operators
> < >= <= && || ! == != === !==
• most logical operators automatically convert types:
5 < "7" is true
42 == 42.0 is true
"5.0" == 5 is true
• === , !== are strict equality tests; checks type and value
"5.0" === 5 is false
22. 22
The if/else statement
if (test) {
statements;
} else if (test) {
statements;
} else {
statements;
}
• identical structure to Java's if/else statement...
but JavaScript allows almost any value as a test!
23. 23
Boolean type
var iLike341 = true;
var ieIsGood = "IE6" > 0; // false
if ("JS is great") { ... } // true
if (0 || "") { ... } // false
• any value can be used as a test
"falsey" values: 0, 0.0, NaN, "", null, and undefined
"truthy" values: anything else
• converting a value into a boolean explicitly:
var boolValue = Boolean(otherValue);
var boolValue = !!(otherValue);
24. 24
&& and || in depth
• a && b is a binary operator that returns:
if a is truthy, then b, else a
(this turns out to be a truthy/falsey value in the right cases)
• a || b is a binary operator that returns:
if a is truthy, then a, else b
(this turns out to be a truthy/falsey value in the right cases)
• Examples:
0 || 42 || 12 || -1 returns 42 (truthy)
NaN || null || "" returns "" (falsey)
1 + 1 && 6 && 9 returns 9 (truthy)
3 && 4 && null && 5 && 6 returns null
(falsey)
25. 25
null vs. undefined
var ned = null;
var benson = 9;
var caroline;
• at this point in the code:
ned is null
benson is 9
caroline is undefined
• undefined: has not been declared, does not exist
• null: exists, but specifically assigned an empty value
Why does JavaScript have both of these?
26. 26
The while loop (same as Java)
while (test) {
statements;
}
do {
statements;
} while (test);
• break and continue keywords also behave as in Java
27. 27
Functions
function name(paramName, ..., paramName) {
statements;
}
function myFunction(name) {
print("Hello, " + name + "!n");
print("How are you?n");
}
unlike in Java, functions are first-class (can be stored as
variables, passed as parameters, returned, ...)
28. 28
JavaScript keywords
break case catch continue debugger
default delete do else finally
for function if in
instanceof
new return switch this throw
try typeof var void while
with
• Reserved words (these don't do anything yet):
class const enum export extends
import implements interface let package
private protected public static super
yield