The document discusses object-oriented programming concepts in JavaScript, including creating custom objects using object literals, constructor functions, and the new operator. It provides examples of defining object properties and methods, and using nested functions to manage the state of buttons for a poker game application. The key topics covered are creating custom objects, defining object properties and methods, object constructor functions, and instantiating objects.
The document discusses the objectives and structure of an HTML5 tutorial, including exploring the history of the web, creating the structure of an HTML document, inserting elements and attributes, and linking to other resources. It covers the basics of HTML5 such as the document type declaration, element tags, attributes, comments, and different types of elements like headings, paragraphs, images, and links.
Chapter 12 Working with Document nodes and style sheetsDr. Ahmed Al Zaidy
This document discusses working with document nodes and style sheets in JavaScript. It covers exploring the node tree structure, creating element and text nodes, and appending nodes to documents. It also discusses creating external and embedded style sheets, adding them to documents, and enabling or disabling style sheets through JavaScript. The document provides examples of how to loop through child nodes, access node properties, and restructure node trees by moving nodes. It also explains working with attribute nodes and style sheet rules.
This document discusses designing web forms in HTML. It covers the basics of forms, including common form controls like text boxes, radio buttons, checkboxes, dropdown lists and more. It also discusses how to lay out forms, add labels and default values, and how forms interact with web servers. The goal is to explore the key elements for creating effective and functional web forms.
This document discusses various CSS concepts including style sheets, selectors, inheritance, and properties for styling text, colors, and fonts. It covers the different types of style sheets like external, embedded, and inline styles. Contextual and attribute selectors are explained. Methods for applying colors like RGB, hex codes, and HSL are provided. The use of web fonts with the @font-face rule is also summarized.
This document discusses working with events and styles in JavaScript. It covers creating event handlers, using the event object, exploring object properties, working with mouse and keyboard events, and controlling event propagation. Specific topics include adding and removing event listeners, changing inline styles, creating object collections with CSS selectors, and changing the cursor style. The overall goal is to teach how to build interactive elements that respond to user input through events.
This document discusses responsive design and flexbox layouts for mobile web design. It covers creating media queries to apply different styles based on screen size, introducing the viewport and its relationship to device width, creating a responsive pulldown menu with CSS, and defining flexbox properties like flex-direction, flex-basis, flex-grow, and flex-shrink to create flexible layouts. The objectives are to make a website render well on devices of various sizes using these responsive design and flexbox techniques.
This document discusses various page layout techniques in CSS including floats, grids, and positioning. It begins by explaining the objectives of creating a reset style sheet, exploring page layout designs, and various positioning techniques. It then covers creating floats, clearing floats, and preventing container collapse. The document ends by discussing grid-based layouts including setting up grids, fixed and fluid grids, and frameworks to support grid layouts.
This document discusses using JavaScript to program web forms. It covers exploring the forms and elements objects to reference form fields and values. Methods are presented for setting field values, navigating between fields, and working with selection lists, radio buttons, check boxes, and hidden fields. The document also discusses formatting numeric values, applying form events, appending form data to URLs, and using regular expressions to extract data. Validation techniques like validating credit card numbers are also mentioned.
The document discusses the objectives and structure of an HTML5 tutorial, including exploring the history of the web, creating the structure of an HTML document, inserting elements and attributes, and linking to other resources. It covers the basics of HTML5 such as the document type declaration, element tags, attributes, comments, and different types of elements like headings, paragraphs, images, and links.
Chapter 12 Working with Document nodes and style sheetsDr. Ahmed Al Zaidy
This document discusses working with document nodes and style sheets in JavaScript. It covers exploring the node tree structure, creating element and text nodes, and appending nodes to documents. It also discusses creating external and embedded style sheets, adding them to documents, and enabling or disabling style sheets through JavaScript. The document provides examples of how to loop through child nodes, access node properties, and restructure node trees by moving nodes. It also explains working with attribute nodes and style sheet rules.
This document discusses designing web forms in HTML. It covers the basics of forms, including common form controls like text boxes, radio buttons, checkboxes, dropdown lists and more. It also discusses how to lay out forms, add labels and default values, and how forms interact with web servers. The goal is to explore the key elements for creating effective and functional web forms.
This document discusses various CSS concepts including style sheets, selectors, inheritance, and properties for styling text, colors, and fonts. It covers the different types of style sheets like external, embedded, and inline styles. Contextual and attribute selectors are explained. Methods for applying colors like RGB, hex codes, and HSL are provided. The use of web fonts with the @font-face rule is also summarized.
This document discusses working with events and styles in JavaScript. It covers creating event handlers, using the event object, exploring object properties, working with mouse and keyboard events, and controlling event propagation. Specific topics include adding and removing event listeners, changing inline styles, creating object collections with CSS selectors, and changing the cursor style. The overall goal is to teach how to build interactive elements that respond to user input through events.
This document discusses responsive design and flexbox layouts for mobile web design. It covers creating media queries to apply different styles based on screen size, introducing the viewport and its relationship to device width, creating a responsive pulldown menu with CSS, and defining flexbox properties like flex-direction, flex-basis, flex-grow, and flex-shrink to create flexible layouts. The objectives are to make a website render well on devices of various sizes using these responsive design and flexbox techniques.
This document discusses various page layout techniques in CSS including floats, grids, and positioning. It begins by explaining the objectives of creating a reset style sheet, exploring page layout designs, and various positioning techniques. It then covers creating floats, clearing floats, and preventing container collapse. The document ends by discussing grid-based layouts including setting up grids, fixed and fluid grids, and frameworks to support grid layouts.
This document discusses using JavaScript to program web forms. It covers exploring the forms and elements objects to reference form fields and values. Methods are presented for setting field values, navigating between fields, and working with selection lists, radio buttons, check boxes, and hidden fields. The document also discusses formatting numeric values, applying form events, appending form data to URLs, and using regular expressions to extract data. Validation techniques like validating credit card numbers are also mentioned.
This document provides an overview of techniques for applying graphical effects to elements using CSS, including:
- Creating figure boxes and adding background images, borders, rounded corners, and gradients.
- Applying transformations, shadows, filters and semi-transparency to elements.
- Introducing 3D transformations and perspective.
- The document contains examples and explanations of CSS properties for each graphical effect.
Chapter 10 Exploring arrays, loops, and conditional statementsDr. Ahmed Al Zaidy
This document discusses using arrays, loops, and conditional statements in JavaScript. It begins by introducing the objectives of creating an array, working with array properties and methods, creating a for loop, using comparison and logical operators, and creating an if conditional statement. It then provides examples and explanations of creating and populating arrays, extracting values from arrays, sorting arrays, and using arrays as data stacks. The overall purpose is to demonstrate various array and loop techniques to generate a monthly calendar using JavaScript.
This document discusses various methods for adding multimedia like audio and video to webpages. It covers HTML5 audio and video elements, supported file formats and codecs, adding captions and subtitles, applying CSS styles, embedding content from sites like YouTube, and using plugins as fallback options. The goal is to understand how to enhance a website with rich multimedia content in an accessible way across different browsers.
This document discusses using tables in HTML and CSS. It covers how to structure tables with <table>, <tr>, <th>, and <td> tags, style tables with CSS including borders and captions, work with rows and columns including grouping and spanning, and make tables responsive. The goal is to teach how to effectively organize and present information using tables and make those tables readable on different devices.
This document provides an overview of JavaScript programming concepts including:
1) It discusses server-side and client-side programming, with JavaScript being a client-side language that runs programs on a user's computer.
2) Core JavaScript concepts are explained such as objects, properties, methods, and how to reference browser and document objects.
3) Techniques for writing JavaScript programs are covered like adding comments, writing commands, debugging code, and working with variables.
The document summarizes BuzzNumbers' transition from using SQL Server to MongoDB as their database. It discusses problems they faced with SQL Server like scalability issues and performance problems with large datasets. It then covers why they chose to use MongoDB, including its ability to scale horizontally and handle large volumes of writes and reads. Finally, it discusses lessons learned in moving to a NoSQL database and using MongoDB and .NET to build their analytics product.
Combine Spring Data Neo4j and Spring Boot to quicklNeo4j
Speakers: Michael Hunger (Neo Technology) and Josh Long (Pivotal)
Spring Data Neo4j 3.0 is here and it supports Neo4j 2.0. Neo4j is a tiny graph database with a big punch. Graph databases are imminently suited to asking interesting questions, and doing analysis. Want to load the Facebook friend graph? Build a recommendation engine? Neo4j's just the ticket. Join Spring Data Neo4j lead Michael Hunger (@mesirii) and Spring Developer Advocate Josh Long (@starbuxman) for a look at how to build smart, graph-driven applications with Spring Data Neo4j and Spring Boot.
GraphConnect Europe 2016 - Building Spring Data Neo4j 4.1 Applications Like A...Neo4j
This document provides an overview of GraphAware and Spring Data Neo4j 4 for building graph applications. It discusses features like object graph mapping, repositories, transactions, and configuration. Entities like Character, Team, and Comic are modeled as nodes and relationships. Repositories provide querying and SDN is configured via Java configuration or properties. GraphAware provides support, documentation, and examples to help developers build graph applications like superheroes.
Webinar: From Relational Databases to MongoDB - What You Need to KnowMongoDB
This document compares relational databases to MongoDB and discusses some key differences in their data models and functionality. MongoDB uses a flexible schema with embedded documents that allows for polymorphism and avoids the object-relational impedance mismatch of relational databases. While relational databases emphasize normalization to reduce redundancy, MongoDB favors denormalization for performance. MongoDB also offers relaxed ACID properties with atomicity at the document level and eventual consistency. To scale, MongoDB uses sharding to partition data across multiple servers.
OrientDB vs Neo4j - and an introduction to NoSQL databasesCurtis Mosters
NoSQL databases are a good alternative to common SQL technologies. Here you get an introduction and comparison of SQL vs NoSQL. Furthermore we have a look on Graph databases and especially OrientDB vs Neo4j.
Neo4j + Tableau Visual Analytics - GraphConnect SF 2015 Neo4j
This document discusses integrating Neo4j graph databases with Tableau visualization software. It describes Tableau as a leader in business intelligence and visual analytics and explains that while Tableau typically works with tables, graphs can also be visualized. It then outlines three ways to connect Neo4j to Tableau - using a web data connector, exporting data to a Tableau data extract file, or publishing directly to Tableau Server. Finally, it provides a roadmap for beta releases integrating Neo4j and Tableau by the end of the year and envisions future capabilities to directly represent graph structures in Tableau.
Generalized framework for using NoSQL DatabasesKIRAN V
This document proposes a generalized framework for using multiple NoSQL databases like HBase and MongoDB. It allows Java objects to be directly inserted, retrieved, updated and deleted from these databases by converting objects to JSON and using database-specific handlers. The framework provides a more convenient interface compared to conventional APIs and improves performance in some cases. It was implemented and its ease of use and performance were evaluated, showing the generalized interface reduces steps for users compared to individual database APIs.
The document provides an overview of NoSQL data modeling concepts and different NoSQL database types including document databases, column-oriented databases, key-value stores, and graph databases. It discusses data modeling approaches for each type and compares databases like MongoDB and CouchDB. The document also covers topics like CAP theorem, eventual consistency, and distributed system techniques from Dynamo.
XML Amsterdam - Creating structure in unstructured dataMarco Gralike
This document discusses various ways to structure unstructured data like Wikipedia articles in an Oracle database. It describes using the XMLType data type with different storage options like object-relational, binary XML, and CLOB. Indexing techniques for structured and unstructured XML data are also covered, including structured XML indexes, unstructured XML indexes, and full-text indexes. The key is choosing a balanced design that optimizes for both data insertion performance and query selection performance based on the specific data and use cases.
The document discusses migrating from an RDBMS to MongoDB. It covers determining if a migration is worthwhile based on evaluating current pain points and target value. It also discusses the roles and responsibilities that will change during a migration, including data architects, developers, DBAs and more. Bulk migration techniques are reviewed including using mongoimport to import JSON data. System cutover is also mentioned as an important part of the migration process.
This document summarizes a MongoDB webinar on advanced schema design patterns. It introduces common schema design patterns like attribute, subset, computed, and approximation patterns. It discusses how to use these patterns to address issues like large documents with many fields, working sets that don't fit in RAM, high CPU usage from repeated calculations, and changing schemas over time. The webinar provides examples of each pattern and encourages learning a common vocabulary for designing MongoDB schemas by applying these reusable patterns.
This document discusses NoSQL databases and frameworks for using them with Java applications. It summarizes the advantages of NoSQL databases, different types including key-value, column-oriented, document and graph databases. It also discusses frameworks like NoSQL Endgame that aim to provide a common API for working with multiple NoSQL databases from Java code. However, it notes that fully supporting all NoSQL databases and scenarios is still a challenge for such frameworks.
The proliferation of data from new data sources has generated greater demand for technologies that can handle and harvest value from unstructured data. Postgres is leading the movement of integrating unstructured data with the relational environment.
Postgres first added JSON and then enhanced it with new data types, functions and operators in recent releases. Now in beta is the JSONB “binary JSON” type. These advances follow the longstanding HStore data type added in 2006 to support key/value stores in Postgres. Now Postgres users can learn how to harness these capabilities to master unstructured data challenges with Postgres.
The presentation also covers:
* An overview of JSON data types and operators
* Examples of SELECT, UPDATE, etc
* An examination of performance considerations
For more information, please email sales@enterprisedb.com
This document discusses various JavaScript techniques for creating animations, working with graphics, accessing data, and validating user input. These include coding animations using recursion and setTimeout, drawing on canvases, sending and receiving data via XMLHttpRequest, loading and saving local files, validating forms with client-side code, using cookies and local storage, and more. Key concepts covered are animation, recursion, createElement, canvas drawing, parsing data, JSON, and data types. Examples are provided for many of these techniques.
Building DSLs with the Spoofax Language WorkbenchEelco Visser
This document discusses the Spoofax language workbench, which is a tool for building domain-specific languages (DSLs). It addresses key concerns in developing DSLs such as the tradeoffs between internal and external DSLs, textual vs graphical syntax, code generation vs interpretation, and static vs dynamic typing. The Spoofax workbench uses declarative syntax definitions and rewrite rules to provide features like syntax checking, error recovery, and incremental processing for integrated development environments.
This document provides an overview of responsive design and flexbox layouts for mobile web development. It introduces media queries for adapting designs based on device features. Flexbox allows flexible sizing of items within a container and different layout options. The document demonstrates how to create responsive designs using media queries and flexible layouts with flexbox to automatically adjust content across devices.
This document discusses responsive design and flexbox layouts for mobile web design. It introduces media queries for adapting styles based on device features. Key aspects covered include:
- The components of responsive design like flexible layouts and media queries.
- Creating media queries using the @media rule and targeting device features.
- Applying media queries in a mobile-first approach with styles for mobile, tablet and desktop.
- Exploring viewports and device widths.
- Creating pulldown menus and flexbox layouts with CSS.
- Testing mobile websites on different devices.
This document provides an overview of techniques for applying graphical effects to elements using CSS, including:
- Creating figure boxes and adding background images, borders, rounded corners, and gradients.
- Applying transformations, shadows, filters and semi-transparency to elements.
- Introducing 3D transformations and perspective.
- The document contains examples and explanations of CSS properties for each graphical effect.
Chapter 10 Exploring arrays, loops, and conditional statementsDr. Ahmed Al Zaidy
This document discusses using arrays, loops, and conditional statements in JavaScript. It begins by introducing the objectives of creating an array, working with array properties and methods, creating a for loop, using comparison and logical operators, and creating an if conditional statement. It then provides examples and explanations of creating and populating arrays, extracting values from arrays, sorting arrays, and using arrays as data stacks. The overall purpose is to demonstrate various array and loop techniques to generate a monthly calendar using JavaScript.
This document discusses various methods for adding multimedia like audio and video to webpages. It covers HTML5 audio and video elements, supported file formats and codecs, adding captions and subtitles, applying CSS styles, embedding content from sites like YouTube, and using plugins as fallback options. The goal is to understand how to enhance a website with rich multimedia content in an accessible way across different browsers.
This document discusses using tables in HTML and CSS. It covers how to structure tables with <table>, <tr>, <th>, and <td> tags, style tables with CSS including borders and captions, work with rows and columns including grouping and spanning, and make tables responsive. The goal is to teach how to effectively organize and present information using tables and make those tables readable on different devices.
This document provides an overview of JavaScript programming concepts including:
1) It discusses server-side and client-side programming, with JavaScript being a client-side language that runs programs on a user's computer.
2) Core JavaScript concepts are explained such as objects, properties, methods, and how to reference browser and document objects.
3) Techniques for writing JavaScript programs are covered like adding comments, writing commands, debugging code, and working with variables.
The document summarizes BuzzNumbers' transition from using SQL Server to MongoDB as their database. It discusses problems they faced with SQL Server like scalability issues and performance problems with large datasets. It then covers why they chose to use MongoDB, including its ability to scale horizontally and handle large volumes of writes and reads. Finally, it discusses lessons learned in moving to a NoSQL database and using MongoDB and .NET to build their analytics product.
Combine Spring Data Neo4j and Spring Boot to quicklNeo4j
Speakers: Michael Hunger (Neo Technology) and Josh Long (Pivotal)
Spring Data Neo4j 3.0 is here and it supports Neo4j 2.0. Neo4j is a tiny graph database with a big punch. Graph databases are imminently suited to asking interesting questions, and doing analysis. Want to load the Facebook friend graph? Build a recommendation engine? Neo4j's just the ticket. Join Spring Data Neo4j lead Michael Hunger (@mesirii) and Spring Developer Advocate Josh Long (@starbuxman) for a look at how to build smart, graph-driven applications with Spring Data Neo4j and Spring Boot.
GraphConnect Europe 2016 - Building Spring Data Neo4j 4.1 Applications Like A...Neo4j
This document provides an overview of GraphAware and Spring Data Neo4j 4 for building graph applications. It discusses features like object graph mapping, repositories, transactions, and configuration. Entities like Character, Team, and Comic are modeled as nodes and relationships. Repositories provide querying and SDN is configured via Java configuration or properties. GraphAware provides support, documentation, and examples to help developers build graph applications like superheroes.
Webinar: From Relational Databases to MongoDB - What You Need to KnowMongoDB
This document compares relational databases to MongoDB and discusses some key differences in their data models and functionality. MongoDB uses a flexible schema with embedded documents that allows for polymorphism and avoids the object-relational impedance mismatch of relational databases. While relational databases emphasize normalization to reduce redundancy, MongoDB favors denormalization for performance. MongoDB also offers relaxed ACID properties with atomicity at the document level and eventual consistency. To scale, MongoDB uses sharding to partition data across multiple servers.
OrientDB vs Neo4j - and an introduction to NoSQL databasesCurtis Mosters
NoSQL databases are a good alternative to common SQL technologies. Here you get an introduction and comparison of SQL vs NoSQL. Furthermore we have a look on Graph databases and especially OrientDB vs Neo4j.
Neo4j + Tableau Visual Analytics - GraphConnect SF 2015 Neo4j
This document discusses integrating Neo4j graph databases with Tableau visualization software. It describes Tableau as a leader in business intelligence and visual analytics and explains that while Tableau typically works with tables, graphs can also be visualized. It then outlines three ways to connect Neo4j to Tableau - using a web data connector, exporting data to a Tableau data extract file, or publishing directly to Tableau Server. Finally, it provides a roadmap for beta releases integrating Neo4j and Tableau by the end of the year and envisions future capabilities to directly represent graph structures in Tableau.
Generalized framework for using NoSQL DatabasesKIRAN V
This document proposes a generalized framework for using multiple NoSQL databases like HBase and MongoDB. It allows Java objects to be directly inserted, retrieved, updated and deleted from these databases by converting objects to JSON and using database-specific handlers. The framework provides a more convenient interface compared to conventional APIs and improves performance in some cases. It was implemented and its ease of use and performance were evaluated, showing the generalized interface reduces steps for users compared to individual database APIs.
The document provides an overview of NoSQL data modeling concepts and different NoSQL database types including document databases, column-oriented databases, key-value stores, and graph databases. It discusses data modeling approaches for each type and compares databases like MongoDB and CouchDB. The document also covers topics like CAP theorem, eventual consistency, and distributed system techniques from Dynamo.
XML Amsterdam - Creating structure in unstructured dataMarco Gralike
This document discusses various ways to structure unstructured data like Wikipedia articles in an Oracle database. It describes using the XMLType data type with different storage options like object-relational, binary XML, and CLOB. Indexing techniques for structured and unstructured XML data are also covered, including structured XML indexes, unstructured XML indexes, and full-text indexes. The key is choosing a balanced design that optimizes for both data insertion performance and query selection performance based on the specific data and use cases.
The document discusses migrating from an RDBMS to MongoDB. It covers determining if a migration is worthwhile based on evaluating current pain points and target value. It also discusses the roles and responsibilities that will change during a migration, including data architects, developers, DBAs and more. Bulk migration techniques are reviewed including using mongoimport to import JSON data. System cutover is also mentioned as an important part of the migration process.
This document summarizes a MongoDB webinar on advanced schema design patterns. It introduces common schema design patterns like attribute, subset, computed, and approximation patterns. It discusses how to use these patterns to address issues like large documents with many fields, working sets that don't fit in RAM, high CPU usage from repeated calculations, and changing schemas over time. The webinar provides examples of each pattern and encourages learning a common vocabulary for designing MongoDB schemas by applying these reusable patterns.
This document discusses NoSQL databases and frameworks for using them with Java applications. It summarizes the advantages of NoSQL databases, different types including key-value, column-oriented, document and graph databases. It also discusses frameworks like NoSQL Endgame that aim to provide a common API for working with multiple NoSQL databases from Java code. However, it notes that fully supporting all NoSQL databases and scenarios is still a challenge for such frameworks.
The proliferation of data from new data sources has generated greater demand for technologies that can handle and harvest value from unstructured data. Postgres is leading the movement of integrating unstructured data with the relational environment.
Postgres first added JSON and then enhanced it with new data types, functions and operators in recent releases. Now in beta is the JSONB “binary JSON” type. These advances follow the longstanding HStore data type added in 2006 to support key/value stores in Postgres. Now Postgres users can learn how to harness these capabilities to master unstructured data challenges with Postgres.
The presentation also covers:
* An overview of JSON data types and operators
* Examples of SELECT, UPDATE, etc
* An examination of performance considerations
For more information, please email sales@enterprisedb.com
This document discusses various JavaScript techniques for creating animations, working with graphics, accessing data, and validating user input. These include coding animations using recursion and setTimeout, drawing on canvases, sending and receiving data via XMLHttpRequest, loading and saving local files, validating forms with client-side code, using cookies and local storage, and more. Key concepts covered are animation, recursion, createElement, canvas drawing, parsing data, JSON, and data types. Examples are provided for many of these techniques.
Building DSLs with the Spoofax Language WorkbenchEelco Visser
This document discusses the Spoofax language workbench, which is a tool for building domain-specific languages (DSLs). It addresses key concerns in developing DSLs such as the tradeoffs between internal and external DSLs, textual vs graphical syntax, code generation vs interpretation, and static vs dynamic typing. The Spoofax workbench uses declarative syntax definitions and rewrite rules to provide features like syntax checking, error recovery, and incremental processing for integrated development environments.
This document provides an overview of responsive design and flexbox layouts for mobile web development. It introduces media queries for adapting designs based on device features. Flexbox allows flexible sizing of items within a container and different layout options. The document demonstrates how to create responsive designs using media queries and flexible layouts with flexbox to automatically adjust content across devices.
This document discusses responsive design and flexbox layouts for mobile web design. It introduces media queries for adapting styles based on device features. Key aspects covered include:
- The components of responsive design like flexible layouts and media queries.
- Creating media queries using the @media rule and targeting device features.
- Applying media queries in a mobile-first approach with styles for mobile, tablet and desktop.
- Exploring viewports and device widths.
- Creating pulldown menus and flexbox layouts with CSS.
- Testing mobile websites on different devices.
This chapter discusses object-oriented programming concepts in JavaScript like encapsulation and interfaces. It covers built-in JavaScript classes like Date, Number, and Math that can be used to manipulate dates, numbers, and perform math functions. The chapter also explains how to define custom JavaScript objects using object literals and constructor functions, and how to add methods and properties to objects.
The document discusses JavaScript statements, functions, arrays, and objects. It provides examples of JavaScript code and explains key concepts like:
- JavaScript statements are separated by semicolons and can span multiple lines.
- Functions are blocks of code that perform tasks and can accept parameters and return values.
- Arrays are special variables that can hold multiple values accessed by index.
- Objects store properties and methods, with properties being name-value pairs that can be accessed directly or via methods.
The document discusses functions and objects in JavaScript. It defines a function as a reusable block of code that performs operations to fulfill a specific task. Functions can be invoked to execute their code. Objects are collections of properties and methods that represent real-world entities. The document describes how to create user-defined functions and objects in JavaScript, including defining properties and methods. It also provides examples of the built-in String and Math objects and their properties and methods.
This document discusses JavaScript objects, including built-in objects like Date and Math, user-defined objects, and prototypal inheritance. It covers:
- Creating Date objects and using methods like getMonth() and toLocaleString() to work with dates
- Math object functions like max(), min(), pow(), and random()
- Creating user-defined objects using literal notation, constructor functions, and dynamically adding properties
- The meaning of 'this' when working with objects
- Achieving encapsulation using closures
- How prototypal inheritance allows objects to inherit properties from other objects
This document provides an introduction to JavaScript including:
1. JavaScript is a client-side scripting language that adds interactivity to HTML pages. It is embedded directly into HTML and allows dynamic updating of content.
2. The document covers JavaScript syntax, variables, data types, functions, objects, arrays, strings, dates and more. It provides examples of how to declare variables, write functions, create objects and arrays, and manipulate strings and dates.
3. Methods for output, variable scope, and built-in objects like String, Array, Math and Date are described. The DOM (Document Object Model) and form validation using JavaScript are also mentioned.
1. JavaScript is a scripting language that originated from LiveScript and was developed by Netscape in 1995 to make web pages more interactive. It was later standardized by Ecma International as ECMAScript.
2. Objects in JavaScript can be created using object literals or the Object constructor. All objects in JavaScript inherit properties and methods from the Object prototype.
3. Functions in JavaScript are objects that allow for abstraction and code reuse. Functions can be defined using function declarations or expressions. All functions have a prototype property that is used to implement prototype-based inheritance.
1. JavaScript is a scripting language used in web browsers. It was originally created to make web pages more interactive and dynamic.
2. The document discusses the history and evolution of JavaScript, including its origins from Scheme and Java, standardization by ECMA, and adoption by major browsers.
3. Key concepts covered include JavaScript objects, functions, and closures. Objects are fundamental data types in JavaScript along with primitives like strings and numbers. Functions are objects that can be assigned to variables or passed as arguments. Closures allow functions to access variables from outer scopes.
This chapter discusses integrating JavaScript with HTML to add dynamic functionality to web pages. It covers inserting <script> tags, defining JavaScript variables, extracting dates, calculating date differences, writing values to the page, and user-defined functions. The chapter objectives are to understand JavaScript language concepts, integrate JavaScript and HTML, and perform various tasks like writing to the page, constructing URLs, and displaying dates.
This document summarizes a presentation on JavaScript essentials for Java developers. It discusses JavaScript object literals, core objects like Array and Date, JSON, and JavaScript classes. Object literals allow creating objects without classes by using this and properties/methods. Core objects like Array, Date, Math and String are explored. JSON is introduced as a lightweight data interchange format. JavaScript classes are explained using the constructor function pattern and prototype properties to add methods to all objects.
The document discusses JSON and how it can be used to summarize data from a NAV database table. It provides examples of creating JSON manually from a Customer table, creating JSON using JSON text writer and JObjects, and converting between JSON and XML. Methods for reading JSON such as JSON readers, XML ports and built-in AL JSON data types are also covered. The workshop aims to help users get familiar with working with JSON in NAV.
The document is a presentation on object oriented JavaScript. It discusses object notations including object constructors and object literals. It covers object properties including data properties, accessor properties, and defining multiple properties. It explains object creation patterns like the factory pattern, constructor pattern, and prototype pattern. It provides details on prototypes including how they work, the prototype chain, and the combination constructor prototype pattern used to address issues with prototypes.
"JavaScript in 2016" by Eduard Tomàs
Some years ago in a far far away company, Brendan Eich created JavaScript. A lot of things happened since then. Times changed, the web grown, the language itself was updated, and we as a developers need to adapt too. Last year the last standard of the language arose: ECMAScript 2015 is here, and has some new and interesting features. In this talk we will show the most relevant ones, and also we will introduce some interesting patterns that you can use in JavaScript: you'll learn how to master the language and made JavaScript your best ally to conquest the world!
This document provides an overview of JavaScript, highlighting both its strengths and weaknesses. It discusses key JavaScript concepts like prototypal inheritance, closures, and modules. It explains how JavaScript simulates classical inheritance using constructor functions and prototypes. Functions can act as constructors, classes, or modules. The document also covers topics like private methods, privileged methods, singletons, and parasitic inheritance. Overall, it presents JavaScript as a language with many contrasts - both powerful features and historical flaws.
W3C HTML5 KIG-How to write low garbage real-time javascriptChanghwan Yi
This document summarizes techniques for writing low-garbage real-time JavaScript code. It discusses how to avoid object allocation using syntax like {} and [] instead of the new keyword. It also recommends reusing objects by wiping their properties instead of creating new ones. Functions should be created at startup instead of during runtime. Vector objects should be returned as individual values instead of vector objects. While avoiding garbage entirely is difficult, these techniques can help craft responsive real-time JavaScript with minimal garbage collector overhead.
Javascript topics covered in the document include prototypes, functions, scope, and "this". Prototypes act like blueprints for objects to inherit properties from. Functions are objects that have a prototype property pointing to their prototype object. Scope is determined by execution contexts and activation objects. The "this" keyword refers to different objects depending on how a function is invoked, such as the containing object for method calls or the global object for regular function calls.
Similar to Chapter 14 Exploring Object-based Programming (20)
An integer overflow occurs when the result of an arithmetic operation exceeds the maximum size of the integer type used to store it. This causes the value to wrap around and can lead to unexpected results. For example, adding 1 to the maximum 8-bit signed integer value of 127 would result in -128 instead of 128. Integer overflows can be exploited by attackers and cause issues like buffer overflows. Developers should choose appropriate integer types that can store all possible values and check for overflow conditions.
This document provides an overview of software testing fundamentals. It discusses why testing is necessary due to human errors that can lead to defects. It then defines software testing as a process used to evaluate a product against requirements and design specifications through execution of tests to detect defects. The document outlines the general test process, including test planning, analysis and design, implementation and execution, evaluating results against exit criteria, and closing testing activities.
The document discusses risk mitigation strategies for network security. It covers assessing threats through formal threat assessments that examine the likelihood and seriousness of potential threats. Risk assessments involve testing systems for vulnerabilities, managing changes to systems, auditing user privileges, and planning for incident response. The document outlines approaches to calculating risk both qualitatively and quantitatively by evaluating the likelihood and potential impact of risks based on historical data from sources like police, insurance companies, and computer incident monitoring organizations. Effective risk mitigation involves knowing potential threats, assessing related risks, and implementing strategies to reduce vulnerabilities and consequences.
The document discusses business continuity, which involves maintaining business operations after disruptive events through business continuity planning, business impact analysis, and disaster recovery planning. It describes business continuity planning as identifying threats, creating preventative and recovery procedures, and testing them. A business impact analysis identifies critical business functions and systems to prioritize in the event of disruption. The disaster recovery plan focuses on restoring IT resources and systems in a documented, tested process following a disruptive event through alternative processing sites and data resynchronization.
The document discusses vulnerability assessment and data security. It explains that vulnerability assessment involves systematically evaluating an enterprise's security posture by identifying assets, evaluating threats, assessing vulnerabilities, analyzing risks, and mitigating risks. This includes inventorying and prioritizing assets, modeling potential threats, cataloging existing weaknesses, estimating the impact of risks, and determining how to address risks. A variety of tools can be used for vulnerability assessment, such as port scanners, vulnerability scanners, and protocol analyzers.
The document discusses access management and control. It defines access management and lists several access control models, including discretionary access control (DAC), mandatory access control (MAC), role-based access control (RBAC), rule-based access control, and attribute-based access control (ABAC). It also discusses how to properly manage access through account setup, naming conventions, time restrictions, and auditing as well as implementing the principle of least privilege.
The document discusses authentication and account management. It describes different types of authentication credentials including what you know (e.g. passwords), what you have (e.g. tokens, cards), and what you are (e.g. biometrics). It outlines weaknesses in traditional password authentication and describes various attacks against passwords like brute force attacks. It also provides recommendations for strengthening password security through techniques like salting, key stretching and using longer random passwords.
The document discusses different types of mobile devices like smartphones, tablets, wearables and portable computers. It describes the risks associated with mobile devices such as vulnerabilities, connection risks and accessing untrusted content. The document also covers ways to secure mobile devices through physical security measures and securing the device itself to prevent unauthorized access.
The document discusses various methods for securing client devices and applications. It describes securing the client by using hardware system security, securing the operating system software, and protecting peripheral devices. Specific techniques discussed include secure booting using UEFI and secure boot standards, establishing a hardware root of trust, preventing electromagnetic spying, and addressing risks from supply chain infections. The document also covers securing the operating system through configuration, patch management, and using antimalware software like antivirus, antispam, and antispyware programs.
The document discusses various types of wireless network attacks including Bluetooth, Near Field Communication (NFC), and Radio Frequency Identification (RFID) attacks. It also covers vulnerabilities in IEEE 802.11 wireless security standards and the evolution of wireless networking standards over time with increasing speeds and capabilities. Common attacks described are bluejacking, bluesnarfing, eavesdropping, man-in-the-middle, and unauthorized access of wireless networks or tagged devices. The document emphasizes the importance of securing wireless networks and devices to prevent such attacks and data theft.
The document discusses administering a secure network. It covers secure network protocols like TCP/IP, SNMP, DNS, and FTP. It describes how to properly place security devices in the network like firewalls, IDS sensors, and DDoS mitigators. It also explains how to analyze security data from logs, devices, software, and tools to identify incidents, violations, and security issues. Managing large volumes of data from multiple sources requires a centralized log analyzer.
Chapter 6Network Security Devices, Design, and TechnologyDr. Ahmed Al Zaidy
The document discusses various network security devices and how they can enhance security. It describes standard networking devices like bridges, switches, routers, and load balancers that have security features built-in. It also covers network security hardware like firewalls, which are specifically designed to provide security. Firewalls inspect packets and either accept or deny entry based on rules defined by the administrator. The document emphasizes that all network devices, both standard and security-focused, need to be properly configured to ensure they strengthen security rather than introduce vulnerabilities.
The document discusses various types of networking and server attacks. It describes networking attacks such as man-in-the-middle attacks, ARP poisoning, and DNS poisoning that target communication between systems. Server attacks like denial of service attacks, SQL injection, and session hijacking are also outlined. The purpose of the document is to explain different attacks that exploit vulnerabilities in networks and servers.
This document discusses advanced cryptography and public key infrastructure (PKI). It covers implementing cryptography, including key strength, algorithms, and cryptographic service providers. It also defines digital certificates, describing how they are used to verify identity through a trusted third party. Finally, it examines the components of PKI, including certificate authorities, digital certificate formats and types, and certificate management protocols.
The document discusses cryptography and provides definitions of key terms like encryption, decryption, plaintext, and ciphertext. It describes different types of cryptographic algorithms including hash algorithms, symmetric algorithms, and asymmetric algorithms. Hash algorithms create a unique digital fingerprint of data, symmetric algorithms use the same key for encryption and decryption, and asymmetric algorithms use a public/private key pair. Specific algorithms are discussed like MD5, SHA, DES, AES, RSA, and elliptic curve cryptography. The document provides an overview of cryptography fundamentals.
The document discusses different types of malware such as viruses, worms, Trojans, ransomware, and crypto-malware. Viruses and worms aim to spread rapidly while Trojans, ransomware, and crypto-malware focus on infecting individual systems. Viruses insert malicious code into files while worms exploit vulnerabilities to spread network. Ransomware encrypts user files until a ransom is paid. Crypto-malware fully encrypts all user files and demands payment to decrypt the files. The document provides examples of how these malware types function and the harm they can cause.
How to Make a Field Mandatory in Odoo 17Celine George
In Odoo, making a field required can be done through both Python code and XML views. When you set the required attribute to True in Python code, it makes the field required across all views where it's used. Conversely, when you set the required attribute in XML views, it makes the field required only in the context of that particular view.
How to Manage Your Lost Opportunities in Odoo 17 CRMCeline George
Odoo 17 CRM allows us to track why we lose sales opportunities with "Lost Reasons." This helps analyze our sales process and identify areas for improvement. Here's how to configure lost reasons in Odoo 17 CRM
Strategies for Effective Upskilling is a presentation by Chinwendu Peace in a Your Skill Boost Masterclass organisation by the Excellence Foundation for South Sudan on 08th and 09th June 2024 from 1 PM to 3 PM on each day.
This slide is special for master students (MIBS & MIFB) in UUM. Also useful for readers who are interested in the topic of contemporary Islamic banking.
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Dr. Vinod Kumar Kanvaria
Exploiting Artificial Intelligence for Empowering Researchers and Faculty,
International FDP on Fundamentals of Research in Social Sciences
at Integral University, Lucknow, 06.06.2024
By Dr. Vinod Kumar Kanvaria
हिंदी वर्णमाला पीपीटी, hindi alphabet PPT presentation, hindi varnamala PPT, Hindi Varnamala pdf, हिंदी स्वर, हिंदी व्यंजन, sikhiye hindi varnmala, dr. mulla adam ali, hindi language and literature, hindi alphabet with drawing, hindi alphabet pdf, hindi varnamala for childrens, hindi language, hindi varnamala practice for kids, https://www.drmullaadamali.com
Walmart Business+ and Spark Good for Nonprofits.pdfTechSoup
"Learn about all the ways Walmart supports nonprofit organizations.
You will hear from Liz Willett, the Head of Nonprofits, and hear about what Walmart is doing to help nonprofits, including Walmart Business and Spark Good. Walmart Business+ is a new offer for nonprofits that offers discounts and also streamlines nonprofits order and expense tracking, saving time and money.
The webinar may also give some examples on how nonprofits can best leverage Walmart Business+.
The event will cover the following::
Walmart Business + (https://business.walmart.com/plus) is a new shopping experience for nonprofits, schools, and local business customers that connects an exclusive online shopping experience to stores. Benefits include free delivery and shipping, a 'Spend Analytics” feature, special discounts, deals and tax-exempt shopping.
Special TechSoup offer for a free 180 days membership, and up to $150 in discounts on eligible orders.
Spark Good (walmart.com/sparkgood) is a charitable platform that enables nonprofits to receive donations directly from customers and associates.
Answers about how you can do more with Walmart!"
2. XPXPXPXPXPObjectives
• Use nested functions
• Create an object literal
• Define object properties and methods
• Define an object class
• Use object constructor functions
• Instantiating an object
New Perspectives on HTML5, CSS3, and JavaScript, 6th Edition 2
3. XPXPXPXPXPObjectives (continued)
• Define an object prototype
• Explore prototype chains
• Use the apply() and call() methods
• Work with objects and arrays
• Create a for…in loop
New Perspectives on HTML5, CSS3, and JavaScript, 6th Edition 3
4. XPXPXPXPXPWorking with Nested Functions
• Any function, including named functions, can
be nested within another function as follows:
function outsideFn() {
commands
function insideFn() {
commands }
commands
}
where
– outsideFn() is the outer or containing function
New Perspectives on HTML5, CSS3, and JavaScript, 6th Edition 4
5. XPXPXPXPXP
Working with Nested Functions
(continued 1)
– insideFn() is the inner or nested function
• Scope of a nested function is limited to the
commands within the containing function
• Nested function is hidden from other code in
the script, making the code contained and
easier to manage
New Perspectives on HTML5, CSS3, and JavaScript, 6th Edition 5
6. XPXPXPXPXP
Working with Nested Functions
(continued 2)
• Example: Nested functions can be used in
developing the poker game app for Arthur’s
Games website
• The app displays the poker table on which
users will play a game of draw poker
New Perspectives on HTML5, CSS3, and JavaScript, 6th Edition 6
8. XPXPXPXPXP
Working with Nested Functions
(continued 4)
• All operations for the game will be stored
within the playDrawPoker() function
• playDrawPoker() function runs automatically
when the page loads
• playDrawPoker() function is created by adding
references to all the buttons on the poker
table
New Perspectives on HTML5, CSS3, and JavaScript, 6th Edition 8
10. XPXPXPXPXP
Working with Nested Functions
(continued 6)
• Elements on the Draw Poker page perform the
following tasks:
– Deal button deals five cards from the poker deck
into the player’s hand
– Draw button replaces all selected cards in the
player’s hand with new cards from the deck
New Perspectives on HTML5, CSS3, and JavaScript, 6th Edition 10
11. XPXPXPXPXP
Working with Nested Functions
(continued 7)
– Stand button signals to the dealer that the player
wants to keep all the cards in the dealt hand
– Reset button restarts the game with a fresh pot,
resetting the bank value to $500
– Bet selection list places the bet before the next
hand is dealt
New Perspectives on HTML5, CSS3, and JavaScript, 6th Edition 11
12. XPXPXPXPXP
Working with Nested Functions
(continued 8)
• The Deal, Draw, and Stand buttons and the Bet
selection list will be turned on and off
depending on the state of the game
• The Draw and Stand buttons are disabled
before the deal
• The Deal button and Bet selection list are
disabled while the current hand is in play
New Perspectives on HTML5, CSS3, and JavaScript, 6th Edition 12
13. XPXPXPXPXP
Working with Nested Functions
(continued 9)
• To disable and enable the buttons, nest the
required functions within the
playDrawPoker() function
• The functions for disabling or enabling the
selected object also set the opacity style of the
selected object
• Disabled objects are semi-transparent on the
page
New Perspectives on HTML5, CSS3, and JavaScript, 6th Edition 13
16. XPXPXPXPXPIntroducing Custom Objects
New Perspectives on HTML5, CSS3, and JavaScript, 6th Edition 16
• There are three kinds of JavaScript objects
– Native objects, such as Date or Array objects,
are part of the JavaScript language
– Host objects are objects provided by the browser
for use in interacting with the web document and
browser, such as the window, document, or form
objects
– Custom objects, also known as user-defined
objects, are objects created by the user for specific
programming tasks
17. XPXPXPXPXPIntroducing Custom Objects (continued 1)
New Perspectives on HTML5, CSS3, and JavaScript, 6th Edition 17
• The following custom objects are created for
the poker game application:
– A poker game object that contains information
about the card game being played
– A poker deck object that contains information
about the cards used in the game
– A poker hand object that contains information
about the hand played by the user in the game
– Poker card objects that contain information about
the individual cards in the poker hand
18. XPXPXPXPXPIntroducing Custom Objects (continued 2)
New Perspectives on HTML5, CSS3, and JavaScript, 6th Edition 18
• A custom object can be defined in one of the
following three ways:
– Creating it as an object literal
– Using an object constructor
– Applying the object create() method
19. XPXPXPXPXPObject Literals
New Perspectives on HTML5, CSS3, and JavaScript, 6th Edition 19
• The general syntax to create a custom object
as an object literal
var objName = {
name1: value1,
name2: value2,
…
};
where
– objName is the name of the object
20. XPXPXPXPXPObject Literals (continued 1)
New Perspectives on HTML5, CSS3, and JavaScript, 6th Edition 20
– name1, name2, and so on are the names
associated with that object
– value1, value2, and so on are the values
assigned to those names
• Each name:value pair contains a property and
property value associated with the object
22. XPXPXPXPXPDot Operators and Bracket Notation
New Perspectives on HTML5, CSS3, and JavaScript, 6th Edition 22
• Dot operator: Connects the object name with
an object property
object.property
• Object properties can also be written using the
bracket notation
object[“property”]
where object is the object name and
property is the object property
23. XPXPXPXPXP
Dot Operators and Bracket Notation
(continued 1)
New Perspectives on HTML5, CSS3, and JavaScript, 6th Edition 23
• Example: The value of the currentBank
property of the pokerGame object could be set
with either
pokerGame.currentBank = 500;
or
pokerGame[“currentBank”] = 500;
24. XPXPXPXPXP
Dot Operators and Bracket Notation
(continued 2)
New Perspectives on HTML5, CSS3, and JavaScript, 6th Edition 24
25. XPXPXPXPXPCreating a Custom Method
New Perspectives on HTML5, CSS3, and JavaScript, 6th Edition 25
• Methods are added to a custom object by
including a function name and its commands
as the following name:value pair:
var objName = {
method: function() {
commands
}
}
where method is the name of the method and
commands are commands run by the method
26. XPXPXPXPXPCreating a Custom Method (continued 1)
New Perspectives on HTML5, CSS3, and JavaScript, 6th Edition 26
• Example: The following code adds the
placeBet() method to the pokerDeck object:
var pokerDeck = {
currentBank: null,
currentBet: null,
placeBet: function() {
this.currentBank -= this.currentBet;
return currentBank;
}
}
27. XPXPXPXPXPCreating a Custom Method (continued 2)
New Perspectives on HTML5, CSS3, and JavaScript, 6th Edition 27
• The placeBet() method uses the this keyword
to reference the current object
• The -= assignment operator is used to subtract
the value of the current bet from the current
bank value
• The method concludes by returning the value
of the currentBank property
28. XPXPXPXPXPCreating a Custom Method (continued 3)
New Perspectives on HTML5, CSS3, and JavaScript, 6th Edition 28
• To apply the placeBet() method to the
pokerDeck object, run the following
expression:
pokerDeck.placeBet()
• Add placeBet() method to the pokerGame
object to reduce the bank value by the size of
the bet
• The placeBet() method should be run
whenever the user clicks the Deal button
29. XPXPXPXPXPCreating a Custom Method (continued 4)
New Perspectives on HTML5, CSS3, and JavaScript, 6th Edition 29
30. XPXPXPXPXPCreating an Object with the new Operator
New Perspectives on HTML5, CSS3, and JavaScript, 6th Edition 30
• Syntax to create a custom object with the
new operator
var objName = new Object();
object.property = value;
object.method = function() {
commands
};
where objName is the object name, property
is a property defined for that object, and
method is a method assigned to that object
31. XPXPXPXPXP
Creating an Object with the new Operator
(continued)
New Perspectives on HTML5, CSS3, and JavaScript, 6th Edition 31
• The new Object() statement is equivalent to
an empty object literal {} that creates an
object devoid of properties and methods
• The biggest limitation of an object created
either as an object literal or with the new
Object() command is that the object is not
reusable
32. XPXPXPXPXPConstructor Functions
New Perspectives on HTML5, CSS3, and JavaScript, 6th Edition 32
• Object class can be created using an object
constructor or a constructor that defines the
properties and methods associated with the
object type
• Object instance or instance: Specific object
that is based on an object class
• Creating the object based on an object class is
known as instantiating an object
33. XPXPXPXPXPConstructor Functions (continued 1)
New Perspectives on HTML5, CSS3, and JavaScript, 6th Edition 33
• Object constructors are defined with the
following constructor function:
function objClass(parameters) {
this.prop1 = value1;
this.prop2 = value2;…
this.method1 = function1;
this.method2 = function2;…
}
where
– objClass is the name of the object class
34. XPXPXPXPXPConstructor Functions (continued 2)
New Perspectives on HTML5, CSS3, and JavaScript, 6th Edition 34
– parameters are the parameters used by the
constructor function
– prop1, prop2, and so on are the properties
associated with that object class
– method1, method2, and so on are the methods
associated with that object class
– this keyword refers to any object instance of the
particular object class
35. XPXPXPXPXPConstructor Functions (continued 3)
New Perspectives on HTML5, CSS3, and JavaScript, 6th Edition 35
• Instances of an object are created with the
following command:
var objInstance = new
objClass(parameters);
where
– objInstance is a specific instance of the object
– objClass is the object class as defined by the
constructor function
– parameters are the values of any parameters
included in the constructor function
37. XPXPXPXPXPCombining Object Classes
New Perspectives on HTML5, CSS3, and JavaScript, 6th Edition 37
• One object class can include objects defined in
other classes
38. XPXPXPXPXPCombining Object Classes (continued 1)
New Perspectives on HTML5, CSS3, and JavaScript, 6th Edition 38
• To instantiate an object from the pokerDeck
class, create a variable named “myDeck” using
the following command:
var myDeck = new pokerDeck();
• The array of pokerCard objects for the myDeck
variable is referenced with the following
expression:
myDeck.cards
39. XPXPXPXPXPCombining Object Classes (continued 2)
New Perspectives on HTML5, CSS3, and JavaScript, 6th Edition 39
• Each card in the deck can be retrieved by
referencing an index in the cards array
• Example: The following expression retrieves
the fourth card from the deck:
myDeck.cards[4]
40. XPXPXPXPXPCombining Object Classes (continued 3)
New Perspectives on HTML5, CSS3, and JavaScript, 6th Edition 40
• All card games require the deck of cards to be
randomly sorted
• The sort() method of Array objects can be
used for random arrangement of the array
items
• Add the shuffle() method to the pokerDeck
object class to randomize the order of items in
the cards array
42. XPXPXPXPXPWorking with Object Prototypes
New Perspectives on HTML5, CSS3, and JavaScript, 6th Edition 42
• Every object has a prototype, which is a
template for all the properties and methods
associated with the object’s class
• When an object is instantiated from a
constructor function, it copies the properties
and methods from the prototype into the new
object
43. XPXPXPXPXPDefining a Prototype Method
New Perspectives on HTML5, CSS3, and JavaScript, 6th Edition 43
• The prototype is itself an object and is
referenced using the following expression:
objName.prototype
where objName is the name of the object class
• Example: The prototype for the pokerCard
class of objects is referenced as follows:
pokerCard.prototype
44. XPXPXPXPXP
Defining a Prototype Method
(continued 1)
New Perspectives on HTML5, CSS3, and JavaScript, 6th Edition 44
• Apply the following command to add a
method to a prototype:
objName.prototype.method = function;
where method is the name of the method and
function is the function applied by the
method
47. XPXPXPXPXPCombining Objects
New Perspectives on HTML5, CSS3, and JavaScript, 6th Edition 47
• Any object class can inherit the properties and
methods from another class using prototypes
• The hierarchy of object classes creates a
prototype chain ranging from superclass to
subclasses
• Superclass: Base object class in a prototype
chain
• Subclasses: Lower classes in a prototype chain
48. XPXPXPXPXPCombining Objects (continued)
New Perspectives on HTML5, CSS3, and JavaScript, 6th Edition 48
• Prototypal inheritance: Process by which the
properties and methods of superclasses are
shared with the subclasses
49. XPXPXPXPXPCreating a Prototype Chain
New Perspectives on HTML5, CSS3, and JavaScript, 6th Edition 49
• A prototype chain is created by defining an
object prototype as an instance of an object
class
• Order of classes is important while defining
the prototype chain
• Start at the top of the hierarchy, and move
down to the lower subclasses
50. XPXPXPXPXP
Creating a Prototype Chain
(continued 1)
New Perspectives on HTML5, CSS3, and JavaScript, 6th Edition 50
• JavaScript resolves the code that references an
object property or method in the following
order:
– Check for the property or method within the
current object instance
– Check for the property or method with the
object’s prototype
51. XPXPXPXPXP
Creating a Prototype Chain
(continued 2)
New Perspectives on HTML5, CSS3, and JavaScript, 6th Edition 51
– If the prototype is an instance of another object,
check for the property or method in that object
– Continue moving down the chain until the
property or method is located or the end of the
chain is reached
• All prototype chains ultimately find their
source in the base object
52. XPXPXPXPXPThe Base Object
New Perspectives on HTML5, CSS3, and JavaScript, 6th Edition 52
• Base object or Object: Fundamental
JavaScript object whose methods are available
to all objects
• A subclass of the base object is created when a
custom object is created using an object literal
or by applying the new Object() command
53. XPXPXPXPXPThe Base Object (continued 1)
New Perspectives on HTML5, CSS3, and JavaScript, 6th Edition 53
54. XPXPXPXPXPThe Base Object (continued 2)
New Perspectives on HTML5, CSS3, and JavaScript, 6th Edition 54
• Example: To determine whether an object
supports a particular property use the
hasOwnProperty() method as follows:
pokerCard.hasOwnProperty(“rank”);
• The code returns true if the pokerCard object
supports the rank property
55. XPXPXPXPXPThe Base Object (continued 3)
New Perspectives on HTML5, CSS3, and JavaScript, 6th Edition 55
• The constructor for Object also supports
methods that can be used to retrieve and
define properties for any object
56. XPXPXPXPXP
Using the apply() and call()
Methods
New Perspectives on HTML5, CSS3, and JavaScript, 6th Edition 56
• Apply or call a method from one object for use
in another object in order to share methods
between objects
• Borrow a method from one object class using
the following apply() method:
function.apply(thisObj [,argArray])
57. XPXPXPXPXP
Using the apply() and call()
Methods (continued 1)
New Perspectives on HTML5, CSS3, and JavaScript, 6th Edition 57
where
– function is a reference to a function
– thisObj is the object that receives the actions of
the function
– argArray is an optional array of argument values
sent to the function
58. XPXPXPXPXP
Using the apply() and call()
Methods (continued 2)
New Perspectives on HTML5, CSS3, and JavaScript, 6th Edition 58
• The call() method is similar to the apply()
method except that the argument values are
placed in a comma-separated list of values
instead of an array
• The syntax of the call() method
function.call(thisObj, arg1, arg2,
arg3, ...)
where arg1, arg2, arg3, and so on is the
comma-separated list of argument values for
function
59. XPXPXPXPXPCombining Objects and Arrays
New Perspectives on HTML5, CSS3, and JavaScript, 6th Edition 59
• A custom object contains data stored in arrays
• JavaScript’s built-in Array object methods
speed up the efficiency of a code by looping
through the contents of an array
60. XPXPXPXPXPApplying the every() Array method
New Perspectives on HTML5, CSS3, and JavaScript, 6th Edition 60
• Use the every() method to test whether
every item in an array matches a specified
condition
• Example: Use every() method to test whether
every card in the cards array of the pokerHand
object has the same value for the suit property
62. XPXPXPXPXP
Creating an Object Literal with the
forEach() Method
New Perspectives on HTML5, CSS3, and JavaScript, 6th Edition 62
• forEach() method is used to run a command
block for each item in an array
63. XPXPXPXPXPApplying a for…in loop
New Perspectives on HTML5, CSS3, and JavaScript, 6th Edition 63
• for…in loop is used to examine the properties
and keys of an object as follows:
for (prop in obj) {
commands
}
where prop references the properties
contained within the obj object
64. XPXPXPXPXPApplying a for…in loop (continued 1)
New Perspectives on HTML5, CSS3, and JavaScript, 6th Edition 64
• Example: Loop through the contents of the
following employee object:
var employee = {
name: “Robert Voiklund”,
position: “manager”,
email: “rvoiklund@example.com” };
• Solution: Apply the following for … in loop:
for (prop in employee) {
console.info(prop + “ is “ +
employee[prop]); }
65. XPXPXPXPXPApplying a for…in loop (continued 2)
New Perspectives on HTML5, CSS3, and JavaScript, 6th Edition 65
• for…in loops do not follow a specific order
because properties can be listed and read out
in any order
• Only the properties that are countable or
enumerable are accessible to for…in loops
66. XPXPXPXPXPApplying a for…in loop (continued 3)
New Perspectives on HTML5, CSS3, and JavaScript, 6th Edition 66
• Determine whether a property is enumerable
using the propertyIsEnumerable() method
obj.propertyIsEnumerable(prop)
where obj is the object and prop is the
property
• Use a for…in loop to loop through every
property in the object
67. XPXPXPXPXPApplying a for…in loop (continued 4)
New Perspectives on HTML5, CSS3, and JavaScript, 6th Edition 67