The document discusses JavaScript closures. It explains that a closure occurs when an inner function is returned from an outer function and still has access to the outer function's variables even after it has returned. This is because closures combine a function and the environment in which that function was created, including any local variables that were in scope. As a result, the inner function can access and use those variables even though the outer function has finished executing. An example is provided to demonstrate how a function can return another function that still has access to the outer function's variables through a closure.
The document is an agenda for a presentation on JavaScript that covers introduction to JavaScript, working with objects, working with functions, details of the object model including public, private, privileged and static members as well as inheritance, and practical closures. It provides explanations and examples of key JavaScript concepts like dynamic and loosely typed features, prototype-based programming, language features such as first-class functions and closures, creating and working with objects and properties, creating functions and using them as objects, and anonymous functions.
Object Oriented Programming In JavaScriptForziatech
This document provides an overview of object oriented programming concepts in JavaScript. It discusses how JavaScript supports OOP through prototypes, functions acting as classes, and constructor functions to initialize objects. The document also covers data types in JavaScript, error handling using try/catch blocks, and techniques to improve performance such as reducing DOM access and unnecessary variables. It provides examples of implementing inheritance, abstraction, polymorphism, and other OOP principles in JavaScript.
This document discusses JavaScript object-oriented programming concepts including inheritance, encapsulation, and polymorphism. It compares classical and prototypal inheritance in JavaScript, describing how JavaScript uses prototypal inheritance with objects inheriting directly from other objects. It also summarizes various object creation patterns in JavaScript including constructor functions, prototypal patterns, and functional patterns.
In JavaScript, almost "everything" is an object.
-Booleans can be objects (if defined with the new keyword)
-Numbers can be objects (if defined with the new keyword)
-Strings can be objects (if defined with the new keyword)
-Dates are always objects
-Maths are always objects
-Regular expressions are always objects
-Arrays are always objects
-Functions are always objects
-Objects are always objects
The document provides an overview of JavaScript programming. It discusses the history and components of JavaScript, including ECMAScript, the DOM, and BOM. It also covers JavaScript basics like syntax, data types, operators, and functions. Finally, it introduces object-oriented concepts in JavaScript like prototype-based programming and early vs. late binding.
This document provides an introduction to JavaScript and its uses for web programming. It explains that JavaScript is a client-side scripting language that allows web pages to become interactive. Some key points covered include:
- JavaScript can change HTML content, styles, validate data, and make calculations.
- Functions are blocks of code that perform tasks when invoked by events or called in code.
- Events like clicks or keyboard presses trigger JavaScript code.
- The DOM (Document Object Model) represents an HTML document that JavaScript can access and modify.
- Forms and user input can be accessed and processed using the DOM.
- Programming flow can be controlled with conditional and loop statements.
-
This document discusses JavaScript prototypes and how they work. It explains that every function has a prototype property that is shared among objects created with that function. It also explains that every object has a hidden __proto__ property that links it to a prototype object. It provides examples of how prototype inheritance works for both classical and prototypal inheritance in JavaScript. Key points covered include how the new operator works, property lookup via the prototype chain, and the relationships between functions, prototypes, and objects in JavaScript.
This document discusses JavaScript objects and object-oriented programming (OOP) in JavaScript. It introduces the author and defines JavaScript as an object-oriented language, noting that everything in JavaScript besides five primitive types (Number, String, Boolean, undefined, null) is an object. It describes creating user-defined objects using the new Object() constructor, functions as objects, object methods, and object literals - a lightweight syntax for creating objects. Examples are provided for each concept to illustrate OOP techniques in JavaScript.
JavaScript language plays a very important role in Web 2.0 application development. JavaScript has its own characteristics different than object-oriented languages and it's not easy for developers to understand.
This presentation covers major advanced topics in JavaScript languages, including prototype chain, identifier resolving, "this" keyword, "new" operator, execution context and scope chain and closure. Besides that, it also covers best practices when using JavaScript.
JavaScript is a scripting language originally designed for web browsers but now used everywhere. It has dynamic typing and supports object-oriented, imperative, and functional programming. JavaScript was created in 1995 and standardized in 1999. It is now the most popular language on GitHub. JavaScript can be used to build interactive web pages, desktop applications, server-side applications, IoT applications, and real-time applications. The core data types in JavaScript are Number, String, Boolean, Object, Function, Array, Date, and Regular Expressions. JavaScript supports features like variables, flow control, error handling, debugging, and JSON for data exchange.
This document provides an introduction to object oriented JavaScript. It covers JavaScript basics like variables, operators, and functions. It discusses objects, prototypes, and inheritance. It explains special functions like bind, call, apply. It covers callbacks, promises, and asynchronous programming. It discusses topics like this, closures, and controlling asynchronous flow. The document is an agenda that provides an overview of key concepts in object oriented JavaScript.
This document provides an introduction to JavaScript and the Document Object Model (DOM). It discusses what JavaScript is, how it can be implemented into web pages, its syntax, data types, functions, and how it interacts with the DOM. JavaScript allows dynamic behavior and interactivity on web pages by accessing and modifying elements and properties of the DOM tree.
This document provides an overview and introduction to JavaScript basics and best practices. It covers what JavaScript is, how engines work, language features, and future developments like ES6. The basics section discusses types, variables, expressions, statements, functions, objects, and prototypical inheritance. The best practices section focuses on techniques for enterprise applications. The document is intended to help front-end developers learn JavaScript fundamentals.
This document provides an agenda and overview of a presentation on JavaScript. It introduces JavaScript, covering its history, cores, uses today, and programming paradigms. It then discusses object-oriented JavaScript, data types and structures, and control statements in JavaScript. The document also mentions functions, prototypes, and JSON before concluding with examples of libraries and frameworks that could be used in a demo program.
This document provides an introduction to JavaScript. It discusses the purposes of JavaScript including making web pages interactive by manipulating pages or responding to user actions. It covers basic JavaScript syntax including variables, data types, operators, conditional statements, and functions. It also discusses event-driven programming in JavaScript and how to attach JavaScript functions to HTML elements as event handlers.
This document discusses object-oriented programming concepts in JavaScript, including encapsulation, inheritance, and polymorphism. It provides examples of implementing encapsulation with private and public properties and methods. Inheritance is demonstrated through extending classes. Polymorphism is shown through functions that can take on different meanings based on context. JSON and closures are also mentioned.
Encapsulation isolates the internal complexity of an object's operation from the rest of the application. Inheritance allows one class to reuse the state and behavior of another class. Polymorphism allows a client to treat different objects in the same way even if they were created from different classes and exhibit different behaviors.
This document discusses JavaScript functions and objects. It explains that functions can return values, run code, and construct objects. It also discusses creating user-defined and built-in objects, accessing and adding properties, and inheritance through the prototype chain. Functions are first-class citizens that can be stored in variables, passed as arguments, and returned from other functions.
C/C++ Programming interview questions and answers document discusses key concepts in C++ including encapsulation, inheritance, polymorphism, constructors, destructors, copy constructors, references, virtual functions, abstract classes, and memory alignment. The document provides definitions and examples to explain each concept.
Objects in JavaScript can be created using object literals, the new keyword, or Object.create(). Objects are collections of properties and methods that are mutable and manipulated by reference. Arrays are objects that represent ordered collections of values of any type and are created using array literals or the Array constructor. Common array methods include concat, join, pop, push, reverse, and sort. The Math object provides common mathematical functions like pow, round, ceil, floor, random, and trigonometric functions.
This was a presentation I wrote for a previous employer, aimed at Java developers. The goal was to help them understand some of the new UI conventions I was putting into their application, so that they would be able to develop "smarter" JSP code.
The document provides an overview of Cappuccino, an Objective-C style framework for building desktop-like web applications. Key points include: Cappuccino allows coding in Objective-C style without CSS, HTML, DOM, or compilation. It runs client-side and supports AJAX calls to remote servers. The document demonstrates how to set up a basic Cappuccino project, write Objective-J classes, use variables and categories, implement delegation, and handle memory management with garbage collection.
Javascript uses prototypal inheritance rather than classical inheritance. In prototypal inheritance, objects inherit directly from other objects by using the object's prototype property. The prototype property allows objects to inherit methods and properties from other objects. When accessing a property on an object, Javascript will search the prototype chain to find the property if it is not present on the object itself. This allows code reuse through prototype chaining. The prototype property of a function sets the prototype of objects created with that function.
JavaScript provides core functionality for web pages and applications. It has a C-like syntax and is dynamically typed. JavaScript code runs on both the client-side in web browsers and the server-side in environments like Node.js. It uses prototype-based inheritance where objects can inherit properties from object prototypes. New features are being added regularly through the ECMAScript specification. JavaScript allows DOM manipulation to modify web pages and event handling for user interactions.
JavaScript is the world's most popular programming language. It is used to add interactive effects to web pages. JavaScript code can be inserted into HTML pages between <script> tags. Common JavaScript statements include conditional statements like if/else and loops. Variables are used to store and manipulate data in JavaScript. Common data types include strings, numbers, booleans, arrays, and objects. Functions allow code reuse and organization. Operators are used to assign values, compare values, and perform arithmetic. jQuery is a popular JavaScript library that simplifies DOM manipulation and event handling.
This document discusses JavaScript objects and object-oriented programming (OOP) in JavaScript. It introduces the author and defines JavaScript as an object-oriented language, noting that everything in JavaScript besides five primitive types (Number, String, Boolean, undefined, null) is an object. It describes creating user-defined objects using the new Object() constructor, functions as objects, object methods, and object literals - a lightweight syntax for creating objects. Examples are provided for each concept to illustrate OOP techniques in JavaScript.
JavaScript language plays a very important role in Web 2.0 application development. JavaScript has its own characteristics different than object-oriented languages and it's not easy for developers to understand.
This presentation covers major advanced topics in JavaScript languages, including prototype chain, identifier resolving, "this" keyword, "new" operator, execution context and scope chain and closure. Besides that, it also covers best practices when using JavaScript.
JavaScript is a scripting language originally designed for web browsers but now used everywhere. It has dynamic typing and supports object-oriented, imperative, and functional programming. JavaScript was created in 1995 and standardized in 1999. It is now the most popular language on GitHub. JavaScript can be used to build interactive web pages, desktop applications, server-side applications, IoT applications, and real-time applications. The core data types in JavaScript are Number, String, Boolean, Object, Function, Array, Date, and Regular Expressions. JavaScript supports features like variables, flow control, error handling, debugging, and JSON for data exchange.
This document provides an introduction to object oriented JavaScript. It covers JavaScript basics like variables, operators, and functions. It discusses objects, prototypes, and inheritance. It explains special functions like bind, call, apply. It covers callbacks, promises, and asynchronous programming. It discusses topics like this, closures, and controlling asynchronous flow. The document is an agenda that provides an overview of key concepts in object oriented JavaScript.
This document provides an introduction to JavaScript and the Document Object Model (DOM). It discusses what JavaScript is, how it can be implemented into web pages, its syntax, data types, functions, and how it interacts with the DOM. JavaScript allows dynamic behavior and interactivity on web pages by accessing and modifying elements and properties of the DOM tree.
This document provides an overview and introduction to JavaScript basics and best practices. It covers what JavaScript is, how engines work, language features, and future developments like ES6. The basics section discusses types, variables, expressions, statements, functions, objects, and prototypical inheritance. The best practices section focuses on techniques for enterprise applications. The document is intended to help front-end developers learn JavaScript fundamentals.
This document provides an agenda and overview of a presentation on JavaScript. It introduces JavaScript, covering its history, cores, uses today, and programming paradigms. It then discusses object-oriented JavaScript, data types and structures, and control statements in JavaScript. The document also mentions functions, prototypes, and JSON before concluding with examples of libraries and frameworks that could be used in a demo program.
This document provides an introduction to JavaScript. It discusses the purposes of JavaScript including making web pages interactive by manipulating pages or responding to user actions. It covers basic JavaScript syntax including variables, data types, operators, conditional statements, and functions. It also discusses event-driven programming in JavaScript and how to attach JavaScript functions to HTML elements as event handlers.
This document discusses object-oriented programming concepts in JavaScript, including encapsulation, inheritance, and polymorphism. It provides examples of implementing encapsulation with private and public properties and methods. Inheritance is demonstrated through extending classes. Polymorphism is shown through functions that can take on different meanings based on context. JSON and closures are also mentioned.
Encapsulation isolates the internal complexity of an object's operation from the rest of the application. Inheritance allows one class to reuse the state and behavior of another class. Polymorphism allows a client to treat different objects in the same way even if they were created from different classes and exhibit different behaviors.
This document discusses JavaScript functions and objects. It explains that functions can return values, run code, and construct objects. It also discusses creating user-defined and built-in objects, accessing and adding properties, and inheritance through the prototype chain. Functions are first-class citizens that can be stored in variables, passed as arguments, and returned from other functions.
C/C++ Programming interview questions and answers document discusses key concepts in C++ including encapsulation, inheritance, polymorphism, constructors, destructors, copy constructors, references, virtual functions, abstract classes, and memory alignment. The document provides definitions and examples to explain each concept.
Objects in JavaScript can be created using object literals, the new keyword, or Object.create(). Objects are collections of properties and methods that are mutable and manipulated by reference. Arrays are objects that represent ordered collections of values of any type and are created using array literals or the Array constructor. Common array methods include concat, join, pop, push, reverse, and sort. The Math object provides common mathematical functions like pow, round, ceil, floor, random, and trigonometric functions.
This was a presentation I wrote for a previous employer, aimed at Java developers. The goal was to help them understand some of the new UI conventions I was putting into their application, so that they would be able to develop "smarter" JSP code.
The document provides an overview of Cappuccino, an Objective-C style framework for building desktop-like web applications. Key points include: Cappuccino allows coding in Objective-C style without CSS, HTML, DOM, or compilation. It runs client-side and supports AJAX calls to remote servers. The document demonstrates how to set up a basic Cappuccino project, write Objective-J classes, use variables and categories, implement delegation, and handle memory management with garbage collection.
Javascript uses prototypal inheritance rather than classical inheritance. In prototypal inheritance, objects inherit directly from other objects by using the object's prototype property. The prototype property allows objects to inherit methods and properties from other objects. When accessing a property on an object, Javascript will search the prototype chain to find the property if it is not present on the object itself. This allows code reuse through prototype chaining. The prototype property of a function sets the prototype of objects created with that function.
JavaScript provides core functionality for web pages and applications. It has a C-like syntax and is dynamically typed. JavaScript code runs on both the client-side in web browsers and the server-side in environments like Node.js. It uses prototype-based inheritance where objects can inherit properties from object prototypes. New features are being added regularly through the ECMAScript specification. JavaScript allows DOM manipulation to modify web pages and event handling for user interactions.
JavaScript is the world's most popular programming language. It is used to add interactive effects to web pages. JavaScript code can be inserted into HTML pages between <script> tags. Common JavaScript statements include conditional statements like if/else and loops. Variables are used to store and manipulate data in JavaScript. Common data types include strings, numbers, booleans, arrays, and objects. Functions allow code reuse and organization. Operators are used to assign values, compare values, and perform arithmetic. jQuery is a popular JavaScript library that simplifies DOM manipulation and event handling.
This document provides an agenda and overview for a presentation on JavaScript. It discusses JavaScript's history and popularity, current implementations of JavaScript engines in browsers, and proliferation of JavaScript frameworks. The agenda outlines discussing objects, functions, scope, primitives, common mistakes, inheritance, best practices, modularity, and more. It also includes code examples demonstrating functions, closures, scope, operators, and error handling in JavaScript.
This document provides an overview of object-oriented programming concepts in JavaScript. It discusses that JavaScript is an object-oriented language that uses prototypes instead of classes. It explains JavaScript's core data types including strings, numbers, Booleans, and objects. It also covers creating custom objects with prototypes, defining methods and properties, public and private members, and inheritance using closures and prototyping. Memory management with closures and the module pattern are also summarized.
Javascript is actually called ECMAScript. The document provides an overview of JavaScript including how it interacts with the DOM in the browser, using JavaScript in web pages, syntax, control structures like loops and conditionals, objects as hashes, functions as first-class objects, loose typing, closures, prototypes, JSON, cross-domain AJAX, libraries like jQuery, and resources for learning more. The global scope in JavaScript is discussed and the importance of using var is emphasized to avoid polluting the global namespace.
- Objects in JavaScript store key-value pairs and can contain nested objects and functions. Functions stored as object properties are called methods.
- The this keyword refers to the object a method is called on. Functions can be declared, assigned to variables as expressions, or used as constructor functions with new.
- Scopes in JavaScript are determined lexically at compile time. Variables are stored in execution contexts and functions form closures by maintaining references to outer scopes even after execution leaves them.
- JavaScript uses prototypal inheritance where objects inherit directly from other objects via the internal [[Prototype]] property. The prototype is used to lookup properties not found on the object itself.
Brief explanation of javascript language for intermediates
Topics Covered
~ Why do we need javascript
~ javascript vs traditional language
~ functions and objects ( sample code )
~ prototypal inheritance ( sample code )
~ variable scope ( sample code )
~ closure (sample code )
~ callbacks
~ events
~ the confusion of 'this'
~ popular frameworks
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.
Video links: Part 1 : http://www.youtube.com/watch?v=lWSV4JLLJ8E Part2 : http://www.youtube.com/watch?v=-MvSBqPlMdY
The document discusses JavaScript and some of its key features:
- JavaScript is the programming language of the web browser and was originally developed by Netscape under different names before being standardized.
- JavaScript uses a prototypal object model instead of classes, with objects inheriting directly from other objects via prototypal inheritance chains rather than from classes.
- The "new" keyword is used to create objects but can give the misleading impression of classes; functions can also be used to create objects without "new" by returning the object.
This document provides an overview of JavaScript concepts and best practices. It discusses objects as hashes, functions as first-class objects, loose typing, closures, prototypes, JSON, cross-domain AJAX, testing with Jasmine, CoffeeScript, libraries like jQuery, global scope issues, regular expressions, XSS, hoisting, and other JavaScript quirks. It also provides resources for further learning JavaScript.
The document discusses JavaScript, describing it as:
- Created in 1995 by Netscape and based on the ECMAScript standard.
- A dynamic, weakly typed, object-oriented programming language that is often misunderstood.
- Used for client-side scripting of webpages as well as server-side and application scripting.
- Commonly disliked due to past bad practices, implementations, and browser differences, but these issues are improving over time.
The document provides an overview of JavaScript objects, functions, and data types. It discusses that JavaScript objects can contain properties and almost everything in JavaScript is an object. Functions are blocks of reusable code that perform tasks when invoked. JavaScript supports primitive data types like strings, numbers, Booleans as well as complex types like objects, arrays. It provides examples and explanations of how to work with each of these concepts in JavaScript.
This document provides an introduction and overview of JavaScript. It begins by introducing the author and stating that JavaScript was originally created in 1995 for web pages. It then discusses that JavaScript is an object-based, interpreted programming language used to control HTML and dynamically create web pages. The document goes on to explain how to write and embed JavaScript code using script tags, and covers JavaScript data types, variables, objects, built-in objects like Math and Date, arrays, functions, and more.
JavaScript is the programming language of the web. It can dynamically manipulate HTML content by changing element properties like innerHTML. Functions allow JavaScript code to run in response to events like button clicks or timeouts. JavaScript uses objects and prototypes to define reusable behaviors and properties for objects. It is an important language for web developers to learn alongside HTML and CSS.
JavaScript - An Introduction is a beginner's guide to JavaScript. It starts with very basic level and goes to intermediate level. You'll be introduced with every language constructs, Event handling, Form handling and AJAX which is supported by JavaScript with XMLHttpRequest object. This XHR object is discussed in enough detail so that you can understand how the underlying AJAX functionality works in jQuery. At the end it discusses advance concepts and library build on/around JavaScript.
The document discusses HTML5 semantic elements and how they can be used to structure web pages in a more transparent way compared to traditional <div> elements. It provides examples of common HTML5 semantic elements like <header>, <nav>, <article>, <section>, and <aside> that can be used instead of <div> for specific sections like navigation, headers, articles, etc. The document also briefly reviews common HTML4 elements like <html>, <head>, <title>, <body>, and heading elements to provide context before discussing the new HTML5 semantic elements.
JavaScript is a scripting language used to add interactivity to web pages. It allows dynamic updating of HTML content using the Document Object Model. Some key features include first-class functions, prototype-based objects without classes, and the ability to modify objects by adding or removing methods at runtime. JavaScript has many security and correctness issues due to its flexibility and lack of type safety.
The Social Health Protection Association in Cambodia is looking for a full-time Field Supervisor for a 6-month research project conducted together with a German university on health insurance and household transfers. The Field Supervisor will manage two survey teams conducting household surveys and ensure high quality data collection. Requirements include a Bachelor's degree, 2 years of fieldwork experience preferably conducting surveys in Cambodia, fluency in Khmer and English, and leadership, teamwork and computer skills. Applications are due by February 28th.
The Cambodian Health Committee (CHC) is seeking a Social Health Protection Project Manager based in Thma Pouk Operational District. The CHC is a leading local NGO focused on health programs including tuberculosis, HIV/AIDS, and maternal and child health. It has been granted funds to manage a Health Equity Fund linked to Community Based Health Insurance. The Project Manager will oversee implementation of the social health protection scheme, provide technical assistance, conduct monitoring and evaluation, and liaise with stakeholders. Applicants should have experience in project management, knowledge of Cambodia's health system, and strong English and computer skills.
The Cambodian Health Committee is seeking to fill 4 Community System Strengthening Coordinator positions based in Kandal and Prey Veng provinces. The CSSCs will monitor and supervise TB and HIV/AIDS programs, organize trainings, prepare reports, and strengthen partnerships between organizations. Applicants should have a bachelor's degree in management, nursing, or related field, knowledge of TB programs and the Global Fund, and strong English, computer, and interpersonal skills.
The Cambodian Health Committee is seeking a Monitoring & Evaluation Officer to develop monitoring plans, indicators, and tools for their tuberculosis and HIV/AIDS programs. The position is based in Phnom Penh with travel to project sites and requires collecting and reporting data, assisting with evaluations, coordinating monitoring processes, and establishing partnerships. Qualified candidates should have a bachelor's degree in a relevant field, monitoring and evaluation experience, knowledge of tuberculosis programs, strong English and computer skills, and strong interpersonal skills.
The Cambodian Health Committee is hiring 5 MDR-TB Nurses to work in various provinces in Cambodia. The nurses will provide care and treatment to MDR-TB patients, work with community health workers to support patients, educate on infection control, and assist with clinical management. Candidates should have a nursing degree or be a medical assistant with TB experience. Applications are due by December 26th.
Outline of consultative workshop on integrated promotion v.1.1 14_oct2014Sopheak Sem
The Royal Government of Cambodia is working to strengthen social health protection and achieve universal health coverage. Currently, different health schemes like the Health Equity Fund and Voucher for Health operate separately. This workshop aims to integrate promotion of these schemes. It will bring together operators of the schemes to share experiences and best practices. Participants will identify and agree on integrated promotion approaches and materials. The workshop will develop detailed content for promotion and finalize agreed upon approaches and materials.
This document provides information about an upcoming training course on Behavior Change Communication conducted over 5 days in October 2012. It will be led by Dr. Chengli Bunty, who has over 20 years of experience in public health. The training aims to help participants determine participatory training methods and skills for developing curriculum and facilitating sessions. The price is $280 but discounts are available. Participants should be project officers, coordinators, or field staff from NGOs/CBOs.
This application form is for an advanced training of trainers program on behavior change communication taking place from October 6-10, 2014. The applicant is asked to provide their personal details such as name, organization, education background, and work experience in health and development fields. The signature of the applicant is required at the bottom.
Outline of sales promotion workshop v 1 2_12aug14Sopheak Sem
The document outlines a 2-day training on sales promotion for field promoters in Pearaing, Cambodia. The training is organized by the Social Health Protection Association (SHPA) and Association of Health Funds (AFH) to improve enrollment in voluntary health insurance membership schemes. A prior needs assessment found sales capacity, especially in addressing complaints, needed strengthening. The training will cover key sales concepts and skills like identifying client needs, presenting products, overcoming objections, and developing an action plan. SHPA and AFH staff will facilitate sessions on sales processes, communication skills, and strategies to overcome challenges. Participants will practice skills and develop a sales procedure and code of conduct to guide their promotional work.
Analysis of-gender-and-emerging-issues-with-focus-on-ageing-population-help a...Sopheak Sem
This document provides an overview of population aging trends in Cambodia and issues related to older populations. Some key points:
- Cambodia has a relatively young population currently but the percentage and number of older persons (aged 60+) is projected to increase significantly by 2050 due to increasing life expectancy.
- Older women outnumber older men and the population is aging more rapidly among women. Many older women live alone and face disadvantages accessing services.
- Currently most older Cambodians live in rural areas and have low levels of education and income insecurity. Health issues rise sharply with age, especially non-communicable diseases. Disability rates are also higher among older Cambodians compared to other ASEAN countries, particularly for women
Ageing&migrationin cambodia26dec2013 (1)Sopheak Sem
The document discusses population aging in Cambodia and how recent demographic trends have impacted and will continue to impact the country's age structure. It notes that while Cambodia currently has a smaller elderly population than other countries, it will experience rapid aging in the coming decades. This is due to declining fertility rates as well as the legacy of high mortality during the Khmer Rouge regime in the 1970s and subsequent baby boom, which set in motion demographic changes that will result in a large aging population in the future. The document uses population pyramids and birth/death rate data to illustrate how events like the Khmer Rouge disrupted Cambodia's typical demographic patterns and age structure compared to other countries.
Cambodia's older people's association guidelines (1)Sopheak Sem
This document provides guidelines for establishing and managing older people's associations (OPAs) in Cambodia. It defines OPAs as community-based organizations that aim to improve the well-being of older people. The guidelines describe the process for establishing an OPA, including mobilizing community support, developing a statute to define the OPA's objectives and organizational structure, and notifying local authorities. It also provides guidance on managing OPAs, such as creating activity plans, financial procedures, and record keeping. The overall goal is to encourage more OPAs across Cambodia and strengthen their ability to address the needs of the country's growing elderly population.
Support for the elderly in cambodia letterSopheak Sem
The document discusses support for the elderly population in Cambodia. Currently, there are over 848,000 people over 60 years old in Cambodia, accounting for 6.3% of the population. This number is estimated to grow significantly to 19% of the population being over 60 by 2050. Many elderly people live in rural areas and suffer from disabilities. The elderly population is considered extremely vulnerable. While there are many NGOs working in Cambodia, only one called HelpAge Cambodia focuses on the elderly. The Ministry of Social Affairs, Veterans and Youth Rehabilitation is responsible for elderly policy and works closely with HelpAge Cambodia on programs to help the elderly. The Ministry is seeking new partner NGOs to work on projects for the elderly
This document announces and provides details about the International Social Protection Studies program from October 2014 to October 2015. The program will train young and mid-level professionals from Cambodia, Laos, Indonesia, the Philippines, and Vietnam in social protection management and policy. Participants will spend time in Germany, Vietnam, and Indonesia developing technical and management skills through coursework, practical training, and an internship. The goal is to build their capacity to contribute to strengthening social protection systems in their home countries.
The document provides terms of reference for a study on commune/sangkat planning and budgeting for social services in Cambodia. The study aims to analyze expenditure trends and identify factors that promote or hamper social service delivery, with a focus on vulnerable groups. It will examine demand for services, participation opportunities, and barriers facing communes. The methodology includes a desk review, key informant interviews, quantitative surveys of households and commune officials in a representative sample of at least 10% of communes. The study will produce recommendations to improve inclusive local governance and enhance participation of the poor and vulnerable in decision-making.
This document is an application form for a training in Community Health Promotion Management from August 04-08, 2014 at MEDiCAM Office in Phnom Penh, Cambodia. It requests the applicant's personal details such as name, sex, date of birth, organization, job title, contact details, educational background, and work experience in health and development. The applicant is asked to provide details of their education after junior high school and describe their past and present health and development work, including part-time and volunteer roles.
This document advertises a 5-day training course on health promotion, management, and community participation. It will be conducted in October 2012 in Phnom Penh, Cambodia by Dr. Chengli Bunty, who has over 20 years of experience in public health. The training fee is $280 but there are discounts for early registration and organizations sending multiple trainees. Participants will gain an understanding of primary healthcare, health education concepts, data collection and analysis, health promotion planning, and the roles of management. The course uses participatory training methods like group discussions and role plays.
Buddhism for Health (BFH) is a local non-profit organization that established a Community-Based Health Insurance (CBHI) scheme called Pagoda Based Health Insurance (PBHI) to provide equitable access to health services for the poor and marginalized. Currently over 10,000 people are voluntarily enrolled in PBHI, which operates in Kirivong District of Takeo Province. It covers services at 20 health centers, 2 hospitals, and takes various measures to ensure quality of care while utilizing a variety of marketing strategies through community participation to promote enrollment. Challenges include a difficult economic environment, issues with quality of care, and the need to strengthen various aspects of the scheme for long-term sustainability.
This document summarizes information about Action for Health's (AFH) community-based health insurance (CBHI) scheme in Kampong Thom province, Cambodia. It provides background on AFH and describes the CBHI scheme's coverage area, enrollment levels, premium structure, benefit package, quality monitoring activities, marketing strategies, challenges faced, and future plans. It also presents a case study of a family that enrolled in the CBHI scheme after their son's appendicitis hospitalization imposed significant financial costs, which were covered once they joined the scheme and the mother later received benefits during her own hospitalization for gastritis.
Contributing to WordPress With & Without Code.pptxPatrick Lumumba
Contributing to WordPress: Making an Impact on the Test Team—With or Without Coding Skills
WordPress survives on collaboration, and the Test Team plays a very important role in ensuring the CMS is stable, user-friendly, and accessible to everyone.
This talk aims to deconstruct the myth that one has to be a developer to contribute to WordPress. In this session, I will share with the audience how to get involved with the WordPress Team, whether a coder or not.
We’ll explore practical ways to contribute, from testing new features, and patches, to reporting bugs. By the end of this talk, the audience will have the tools and confidence to make a meaningful impact on WordPress—no matter the skill set.
Introduction and Background:
Study Overview and Methodology: The study analyzes the IT market in Israel, covering over 160 markets and 760 companies/products/services. It includes vendor rankings, IT budgets, and trends from 2025-2029. Vendors participate in detailed briefings and surveys.
Vendor Listings: The presentation lists numerous vendors across various pages, detailing their names and services. These vendors are ranked based on their participation and market presence.
Market Insights and Trends: Key insights include IT market forecasts, economic factors affecting IT budgets, and the impact of AI on enterprise IT. The study highlights the importance of AI integration and the concept of creative destruction.
Agentic AI and Future Predictions: Agentic AI is expected to transform human-agent collaboration, with AI systems understanding context and orchestrating complex processes. Future predictions include AI's role in shopping and enterprise IT.
Droidal: AI Agents Revolutionizing HealthcareDroidal LLC
Droidal’s AI Agents are transforming healthcare by bringing intelligence, speed, and efficiency to key areas such as Revenue Cycle Management (RCM), clinical operations, and patient engagement. Built specifically for the needs of U.S. hospitals and clinics, Droidal's solutions are designed to improve outcomes and reduce administrative burden.
Through simple visuals and clear examples, the presentation explains how AI Agents can support medical coding, streamline claims processing, manage denials, ensure compliance, and enhance communication between providers and patients. By integrating seamlessly with existing systems, these agents act as digital coworkers that deliver faster reimbursements, reduce errors, and enable teams to focus more on patient care.
Droidal's AI technology is more than just automation — it's a shift toward intelligent healthcare operations that are scalable, secure, and cost-effective. The presentation also offers insights into future developments in AI-driven healthcare, including how continuous learning and agent autonomy will redefine daily workflows.
Whether you're a healthcare administrator, a tech leader, or a provider looking for smarter solutions, this presentation offers a compelling overview of how Droidal’s AI Agents can help your organization achieve operational excellence and better patient outcomes.
A free demo trial is available for those interested in experiencing Droidal’s AI Agents firsthand. Our team will walk you through a live demo tailored to your specific workflows, helping you understand the immediate value and long-term impact of adopting AI in your healthcare environment.
To request a free trial or learn more:
https://droidal.com/
As data privacy regulations become more pervasive across the globe and organizations increasingly handle and transfer (including across borders) meaningful volumes of personal and confidential information, the need for robust contracts to be in place is more important than ever.
This webinar will provide a deep dive into privacy contracting, covering essential terms and concepts, negotiation strategies, and key practices for managing data privacy risks.
Whether you're in legal, privacy, security, compliance, GRC, procurement, or otherwise, this session will include actionable insights and practical strategies to help you enhance your agreements, reduce risk, and enable your business to move fast while protecting itself.
This webinar will review key aspects and considerations in privacy contracting, including:
- Data processing addenda, cross-border transfer terms including EU Model Clauses/Standard Contractual Clauses, etc.
- Certain legally-required provisions (as well as how to ensure compliance with those provisions)
- Negotiation tactics and common issues
- Recent lessons from recent regulatory actions and disputes
Microsoft Build 2025 takeaways in one presentationDigitalmara
Microsoft Build 2025 introduced significant updates. Everything revolves around AI. DigitalMara analyzed these announcements:
• AI enhancements for Windows 11
By embedding AI capabilities directly into the OS, Microsoft is lowering the barrier for users to benefit from intelligent automation without requiring third-party tools. It's a practical step toward improving user experience, such as streamlining workflows and enhancing productivity. However, attention should be paid to data privacy, user control, and transparency of AI behavior. The implementation policy should be clear and ethical.
• GitHub Copilot coding agent
The introduction of coding agents is a meaningful step in everyday AI assistance. However, it still brings challenges. Some people compare agents with junior developers. They noted that while the agent can handle certain tasks, it often requires supervision and can introduce new issues. This innovation holds both potential and limitations. Balancing automation with human oversight is crucial to ensure quality and reliability.
• Introduction of Natural Language Web
NLWeb is a significant step toward a more natural and intuitive web experience. It can help users access content more easily and reduce reliance on traditional navigation. The open-source foundation provides developers with the flexibility to implement AI-driven interactions without rebuilding their existing platforms. NLWeb is a promising level of web interaction that complements, rather than replaces, well-designed UI.
• Introduction of Model Context Protocol
MCP provides a standardized method for connecting AI models with diverse tools and data sources. This approach simplifies the development of AI-driven applications, enhancing efficiency and scalability. Its open-source nature encourages broader adoption and collaboration within the developer community. Nevertheless, MCP can face challenges in compatibility across vendors and security in context sharing. Clear guidelines are crucial.
• Windows Subsystem for Linux is open-sourced
It's a positive step toward greater transparency and collaboration in the developer ecosystem. The community can now contribute to its evolution, helping identify issues and expand functionality faster. However, open-source software in a core system also introduces concerns around security, code quality management, and long-term maintenance. Microsoft’s continued involvement will be key to ensuring WSL remains stable and secure.
• Azure AI Foundry platform hosts Grok 3 AI models
Adding new models is a valuable expansion of AI development resources available at Azure. This provides developers with more flexibility in choosing language models that suit a range of application sizes and needs. Hosting on Azure makes access and integration easier when using Microsoft infrastructure.
Introducing the OSA 3200 SP and OSA 3250 ePRCAdtran
Adtran's latest Oscilloquartz solutions make optical pumping cesium timing more accessible than ever. Discover how the new OSA 3200 SP and OSA 3250 ePRC deliver superior stability, simplified deployment and lower total cost of ownership. Built on a shared platform and engineered for scalable, future-ready networks, these models are ideal for telecom, defense, metrology and more.
Evaluation Challenges in Using Generative AI for Science & Technical ContentPaul Groth
Evaluation Challenges in Using Generative AI for Science & Technical Content.
Foundation Models show impressive results in a wide-range of tasks on scientific and legal content from information extraction to question answering and even literature synthesis. However, standard evaluation approaches (e.g. comparing to ground truth) often don't seem to work. Qualitatively the results look great but quantitive scores do not align with these observations. In this talk, I discuss the challenges we've face in our lab in evaluation. I then outline potential routes forward.
Improving Developer Productivity With DORA, SPACE, and DevExJustin Reock
Ready to measure and improve developer productivity in your organization?
Join Justin Reock, Deputy CTO at DX, for an interactive session where you'll learn actionable strategies to measure and increase engineering performance.
Leave this session equipped with a comprehensive understanding of developer productivity and a roadmap to create a high-performing engineering team in your company.
GDG Cloud Southlake #43: Tommy Todd: The Quantum Apocalypse: A Looming Threat...James Anderson
The Quantum Apocalypse: A Looming Threat & The Need for Post-Quantum Encryption
We explore the imminent risks posed by quantum computing to modern encryption standards and the urgent need for post-quantum cryptography (PQC).
Bio: With 30 years in cybersecurity, including as a CISO, Tommy is a strategic leader driving security transformation, risk management, and program maturity. He has led high-performing teams, shaped industry policies, and advised organizations on complex cyber, compliance, and data protection challenges.
AI Emotional Actors: “When Machines Learn to Feel and Perform"AkashKumar809858
Welcome to the era of AI Emotional Actors.
The entertainment landscape is undergoing a seismic transformation. What started as motion capture and CGI enhancements has evolved into a full-blown revolution: synthetic beings not only perform but express, emote, and adapt in real time.
For reading further follow this link -
https://akash97.gumroad.com/l/meioex
Neural representations have shown the potential to accelerate ray casting in a conventional ray-tracing-based rendering pipeline. We introduce a novel approach called Locally-Subdivided Neural Intersection Function (LSNIF) that replaces bottom-level BVHs used as traditional geometric representations with a neural network. Our method introduces a sparse hash grid encoding scheme incorporating geometry voxelization, a scene-agnostic training data collection, and a tailored loss function. It enables the network to output not only visibility but also hit-point information and material indices. LSNIF can be trained offline for a single object, allowing us to use LSNIF as a replacement for its corresponding BVH. With these designs, the network can handle hit-point queries from any arbitrary viewpoint, supporting all types of rays in the rendering pipeline. We demonstrate that LSNIF can render a variety of scenes, including real-world scenes designed for other path tracers, while achieving a memory footprint reduction of up to 106.2x compared to a compressed BVH.
https://arxiv.org/abs/2504.21627
Securiport is a border security systems provider with a progressive team approach to its task. The company acknowledges the importance of specialized skills in creating the latest in innovative security tech. The company has offices throughout the world to serve clients, and its employees speak more than twenty languages at the Washington D.C. headquarters alone.
Agentic AI Explained: The Next Frontier of Autonomous Intelligence & Generati...Aaryan Kansari
Agentic AI Explained: The Next Frontier of Autonomous Intelligence & Generative AI
Discover Agentic AI, the revolutionary step beyond reactive generative AI. Learn how these autonomous systems can reason, plan, execute, and adapt to achieve human-defined goals, acting as digital co-workers. Explore its promise, key frameworks like LangChain and AutoGen, and the challenges in designing reliable and safe AI agents for future workflows.
Sticky Note Bullets:
Definition: Next stage beyond ChatGPT-like systems, offering true autonomy.
Core Function: Can "reason, plan, execute and adapt" independently.
Distinction: Proactive (sets own actions for goals) vs. Reactive (responds to prompts).
Promise: Acts as "digital co-workers," handling grunt work like research, drafting, bug fixing.
Industry Outlook: Seen as a game-changer; Deloitte predicts 50% of companies using GenAI will have agentic AI pilots by 2027.
Key Frameworks: LangChain, Microsoft's AutoGen, LangGraph, CrewAI.
Development Focus: Learning to think in workflows and goals, not just model outputs.
Challenges: Ensuring reliability, safety; agents can still hallucinate or go astray.
Best Practices: Start small, iterate, add memory, keep humans in the loop for final decisions.
Use Cases: Limited only by imagination (e.g., drafting business plans, complex simulations).
European Accessibility Act & Integrated Accessibility TestingJulia Undeutsch
Emma Dawson will guide you through two important topics in this session.
Firstly, she will prepare you for the European Accessibility Act (EAA), which comes into effect on 28 June 2025, and show you how development teams can prepare for it.
In the second part of the webinar, Emma Dawson will explore with you various integrated testing methods and tools that will help you improve accessibility during the development cycle, such as Linters, Storybook, Playwright, just to name a few.
Focus: European Accessibility Act, Integrated Testing tools and methods (e.g. Linters, Storybook, Playwright)
Target audience: Everyone, Developers, Testers
Supercharge Your AI Development with Local LLMsFrancesco Corti
In today's AI development landscape, developers face significant challenges when building applications that leverage powerful large language models (LLMs) through SaaS platforms like ChatGPT, Gemini, and others. While these services offer impressive capabilities, they come with substantial costs that can quickly escalate especially during the development lifecycle. Additionally, the inherent latency of web-based APIs creates frustrating bottlenecks during the critical testing and iteration phases of development, slowing down innovation and frustrating developers.
This talk will introduce the transformative approach of integrating local LLMs directly into their development environments. By bringing these models closer to where the code lives, developers can dramatically accelerate development lifecycles while maintaining complete control over model selection and configuration. This methodology effectively reduces costs to zero by eliminating dependency on pay-per-use SaaS services, while opening new possibilities for comprehensive integration testing, rapid prototyping, and specialized use cases.
Maxx nft market place new generation nft marketing placeusersalmanrazdelhi
PREFACE OF MAXXNFT
MaxxNFT: Powering the Future of Digital Ownership
MaxxNFT is a cutting-edge Web3 platform designed to revolutionize how
digital assets are owned, traded, and valued. Positioned at the forefront of the
NFT movement, MaxxNFT views NFTs not just as collectibles, but as the next
generation of internet equity—unique, verifiable digital assets that unlock new
possibilities for creators, investors, and everyday users alike.
Through strategic integrations with OKT Chain and OKX Web3, MaxxNFT
enables seamless cross-chain NFT trading, improved liquidity, and enhanced
user accessibility. These collaborations make it easier than ever to participate
in the NFT ecosystem while expanding the platform’s global reach.
With a focus on innovation, user rewards, and inclusive financial growth,
MaxxNFT offers multiple income streams—from referral bonuses to liquidity
incentives—creating a vibrant community-driven economy. Whether you
'
re
minting your first NFT or building a digital asset portfolio, MaxxNFT empowers
you to participate in the future of decentralized value exchange.
https://maxxnft.xyz/
Adtran’s SDG 9000 Series brings high-performance, cloud-managed Wi-Fi 7 to homes, businesses and public spaces. Built on a unified SmartOS platform, the portfolio includes outdoor access points, ceiling-mount APs and a 10G PoE router. Intellifi and Mosaic One simplify deployment, deliver AI-driven insights and unlock powerful new revenue streams for service providers.
2. 2
Agenda
Introduction to JavaScript
Working with Objects
Working with Functions
Working with Closures
Details of the Object Model
Public Members
Private Members
Privileged Members
Static Members
Inheritance
Practical Closures
4. 4
IntroductiontoJavaScript
JavaScript has a reasonable claim to being the
world’s most misunderstood programming
language.
JavaScript is a scripting language most often used
for client-side web development.
Major implementations are SpiderMonkey, Rhino,
KJS, JavaScriptCore, and V8.
It is a dynamic, weakly typed, prototype-based
language with first-class functions.
5. 5
DynamicLanguage
A high level of programming languages that
execute many common behaviors at runtime.These
behaviors could include:
Extension of the program,
By adding new code,
By extending objects and definitions,
Or by modifying the type system.
Dynamic languages and dynamic typing are not
identical concepts, and a dynamic language need
not be dynamically typed, though many dynamic
languages are dynamically typed.
6. 6
ALooselyTypedLanguage
In JavaScript, you do not declare a type when defining a
variable. However, this does not mean that variables are not
typed. Depending on what data it contains, a variable can
have one of several types.
A variable can change its type, depending on what value is
assigned to it.The primitive datatypes can also be cast from
one type to another.
There are three primitive types: booleans, numbers, and
strings.
There are functions, which contain executable code.There
are objects, which are composite datatypes.
Lastly, there are the null and undefined datatypes. Primitive
datatypes are passed by value, while all other datatypes are
passed by reference.
7. 7
Prototyped-basedProgramming
A style of object-oriented programming in which
classes are not present, and behavior reuse (known
as inheritance in class-based languages) is
performed via a process of cloning existing objects
that serve as prototypes.This model can also be
known as class-less, prototype-oriented or instance-
based programming.
In prototype-based systems there are two methods
of constructing new objects, through cloning of an
existing object, and through ex nihilo ("from
nothing") object creation.
8. 8
LanguageFeatures
Structured
JavaScript supports all the structured programming syntax in C (e.g., if
statements, while loops, switch statements, etc.). One partial exception is
scoping:C-style block-level scoping is not supported. JavaScript 1.7, however,
supports block-level scoping with the let keyword. Like C, JavaScript makes a
distinction between expressions and statements.
Dynamic
dynamic typing
Types are associated with values, not variables.
JavaScript supports duck typing.
objects as associative arrays
JavaScript is heavily object-based. Objects are associative arrays. Properties
and their values can be added, changed, or deleted at run-time.
run-time evaluation
JavaScript includes an eval function that can execute statements provided as
strings at run-time.
9. 9
LanguageFeatures(cont.)
Functional
first-class functions
Functions are first-class; they are objects themselves. As such, they have
properties and can be passed around and interacted with like any other objects.
first-class functions treats functions as first-class objects. Specifically, this
means that the language supports constructing new functions during the
execution of a program, storing them in data structures, passing them as
arguments to other functions, and returning them as the values of other
functions.
inner functions and closures
Inner functions (functions defined within other functions) are created each
time the outer function is invoked, and variables of the outer functions for that
invocation continue to exist as long as the inner functions still exist, even after
that invocation is finished (e.g. if the inner function was returned, it still has
access to the outer function's variables) — this is the mechanism behind closures
within JavaScript.
10. 10
LanguageFeatures(cont.)
Prototype-based
prototypes
JavaScript uses prototypes instead of classes for defining object properties,
including methods, and inheritance. It is possible to simulate many class-based
features with prototypes in JavaScript.
functions as object constructors
Functions double as object constructors along with their typical role.
Prefixing a function call with new creates a new object and calls that function
with its local this keyword bound to that object for that invocation. The function's
prototype property determines the new object's prototype.
functions as methods
Unlike many object-oriented languages, there is no distinction between a
function definition and a method definition. Rather, the distinction occurs during
function calling; a function can be called as a method. When a function is invoked
as a method of an object, the function's local this keyword is bound to that object
for that invocation.
11. 11
LanguageFeatures(cont.)
Others
run-time environment
JavaScript typically relies on a run-time environment (e.g. in a web browser)
to provide objects and methods by which scripts can interact with "the outside
world". (This is not a language feature, but it is common in most JavaScript
implementations.)
variadic functions
An indefinite number of parameters can be passed to a function. The
function can both access them through formal parameters and the local
arguments object.
array and object literals
Like many scripting languages, arrays and objects (associative arrays in
other languages) can be created with a succinct shortcut syntax. The object literal
in particular is the basis of the JSON data format.
regular expressions
JavaScript also supports regular expressions in a manner similar to Perl.
13. 13
Objects
JavaScript is fundamentally about objects. Array
are objects. Functions are objects. Objects are
objects.
What are objects?
Objects are collections of name-value pairs.The
names are strings, and the values are string,
numbers, booleans, and objects.
14. 14
ObjectsandProperties
You define a property of an object by assigning it a value.
myCar.make = “Ford”;
JavaScript objects are sometimes called associative arrays,
since each property is associated with a string value that can
be used to access it.
Properties of JavaScript objects can be accessed or set using
a dot notation or bracket notation.
myCar.make = “Ford”;
or myCar[“make”] = “Ford”;
or var propertyName = “make”;
myCar[propertyName] = “Ford”;
15. 15
ObjectsandProperties(cont.)
You can use the bracket notation with for…in to iterate
over all the properties of an object.
function showProperties(obj, objName) {
var result = “”;
for(var i in obj)
result += objName + “.” + i + “ = “ + obj[i] + “n”;
return result;
}
myCar.make = Ford
myCar.model = Mustang
myCar.year = 1969
16. 16
CreatingNewObjects
You can create an object using an object
initializer.
var obj = { property_1: value_1,
property_2: value_2,
property_n: value_n };
Alternatively, you can create an object with
these two steps:
1. Define the object type by writing a constructor
function.
2. Create an instance of the object with new.
17. 17
CreatingNewObjects(cont.)
function Car(make, model, year) {
this.make = make;
this.model = model;
this.year = year;
}
Now, you can create an object called myCar as follows:
myCar = new Car(“Eagle”, “Talon TSi”, 1993);
You can create any number of car objects by calls to new.
An object can have a property that is itself another object.
18. 18
IndexingObjectProperties
In JavaScript 1.1 or later,
if you initially define a property by its name, you
must always refer to it by its name,
myCar.color = “red”;
and if you initially define a property by an index,
you must always refer to it by its index.
myCar[5] = “25 mpg”;
19. 19
DefinePropertiesforanObjectType
You can add a property defined object by using
the prototype property.
Car.prototype.color = “red”;
car1.color = “blue”;
This defines a property that is shared by all
objects of the specified type, rather than by just
one instance of the object.
20. 20
DefineMethods
A method is a function associated with an
object.You define a method by:
object.methodname = function_name;
You can then call the method in the context of
the object as follows:
object.methodname(params);
22. 22
DeletingProperties
You can remove a property by using the delete operator.
//create a new object with two properties: a and b.
myObj = new Object();
myObj.a = 5;
myObj.b = 12;
delete myObj.a; //remove the a property
24. 24
FunctionObject
A JavaScript function can take 0 or more named
parameters.
The function body can declare its own variables
which are local to that function.
If no return statement is used, JavaScript returns
undefined.
function add(x, y) {
var total = x + y;
return total;
}
25. 25
FunctionsAsFirst-ClassObjects
In JavaScript, functions are first-class objects.They can be
stored in variables, passed into other functions as
arguments, passed out of functions as return values, and
constructed at run-time.
You can create anonymous functions, which are functions
created using the function() { ... } syntax.They are not given
names, but they can be assigned to variables.
JavaScript has function-level scope.
JavaScript is also lexically scoped, which means that
functions run in the scope they are defined in, not the scope
they are executed in.
26. 26
FunctionArguments
JavaScript functions can be invoked with any
number of arguments, regardless of the number of
arguments named in the function definition.
You can call a function without passing the
parameters it expects, in which case they will be set
to underfined.
add(); //NaN
You can also pass in more arguments than the
function is expecting:
add(2, 3, 4); //5
27. 27
Theargumentsobject
Functions have access to an additional variable
inside their body called arguments, which is an
array-like object holding all of the values passed to
the function.
function add() {
var sum = 0;
for(var i=0; i<arguments.length; i++) {
sum += arguments[i];
}
return sum;
}
add(2, 3, 4, 5); //14
28. 28
Theargumentsobject(cont.)
The arguments object defines a callee property
that refers to the function that is currently being
executed.This property is rarely useful, but it can be
used to allow unnamed functions to invoke
themselves recursively.
function(x) {
if (x <= 1) return 1;
return x * arguments.callee(x-1);
}
29. 29
FunctionsasData
In JavaScript, however, functions are also data, which means
that they can be assigned to variables, stored in the
properties of objects or the elements of arrays, passed as
arguments to functions, and so on.
function square(x) { return x*x; }
var a = square(4); // a contains the number 16
var b = square; // Now b refers to square
var c = b(5); // c contains the number 25
var o = new Object();
o.square = function(x) { return x*x; }
y = o.square(16); // y equals 256
30. 30
ConstructorFunctions
A constructor function is a function that
initializes the properties of an object and is
intended for use with the new operator.
function Car(make, model, year, owner) {
this.make = make;
this.model = model;
this.year = year;
this.owner = owner;
}
31. 31
FunctionPropertiesandMethods
The length property of the arguments array specifies the
number of arguments that were passed to the function.
The length property of the Function object returns exactly
how many declared parameters a function has.
Note that unlike arguments.length, this length property is
available both inside and outside of the function body.
function check(args) {
var actual = args.length;
var expected = args.callee.length;
if (actual != expected) {
throw new Error("Wrong number of arguments:
expected: " + expected + "; actually passed " + actual);
}
}
32. 32
DefiningYourOwnFunctionProperties
When a function needs to use a variable whose
value persists across invocations, it is often
convenient to use a property of the Function object,
instead of cluttering up the namespace by defining
a global variable.
function counter() {
if (!arguments.callee.count) {
arguments.callee.count = 0;
}
return arguments.callee.count++;
}
33. 33
Theapply() andcall() Methods
These methods allow you to invoke a function as if it
were a method of some other object.
The first argument to both call() and apply() is
the object on which the function is to be invoked;
this argument becomes the value of the this
keyword within the body of the function.
Any remaining arguments to call() are the values
that are passed to the function that is invoked.
34. 34
Theapply() andcall() Methods
f.call(o, 1, 2);
This is similar to the following lines of code:
o.m = f;
o.m(1,2);
delete o.m;
The apply() method is like the call() method,
except that the arguments to be passed to the
function are specified as an array:
f.apply(o, [1, 2]);
35. 35
AnonymousFunctions
An anonymous function, executed immediately.
(function() {
var foo = 10;
var bar = 2;
alert(foo * bar);
})();
An anonymous function with arguments.
(function(foo, bar) {
alert(foo * bar);
})(10, 2);
An anonymous function that returns a value.
var baz = (function(foo, bar) {
return foo * bar;
})(10, 2);
36. 36
AnonymousFunctions(cont.)
Here’s a way of “hiding” some local variables – like
block scope in C:
> var a = 1;
> var b = 2;
> (function() {
var b = 3;
a += b;
})();
> a
4
> b
2
37. 37
InnerFunctions
JavaScript function declarations are allowed inside
other functions.
An important detail of nested functions in
JavaScript is that they can access variables in their
parent function’s scope.
function betterExampleNeeded() {
var a = 1;
function oneMoreThanA() {
return a + 1;
}
return oneMoreThanA();
}
39. 39
WorkingwithClosures
Closures are often considered an advanced feature in JavaScript, but
understanding them is essential to mastering the language.
JavaScript allows inner functions.
And that those inner functions are allowed access to all of the local
variables, parameters and declared inner functions within their outer
function(s).
A closure is formed when one of those inner functions is made accessible
outside of the function in which it was contained, so that it may be
executed after the outer function has returned.
At which point it still has access to the local variables, parameters and
inner function declarations of its outer function.
41. 41
WorkingwithClosures(cont.)
This is an example of lexical scoping: in JavaScript, the
scope of a variable is defined by its location within the
source code, and nested functions have access to
variables declared in their outer scope.
Now consider the following example:
function makeFunc() {
var name = “Mozilla”;
function displayName() {
alert(name);
}
return displayName;
}
var myFunc = makeFunc();
myFunc();
42. 42
WorkingwithClosures(cont.)
The displayName() inner function was
returned from the outer function before being
executed.
Normally, the local variables within a function
only exist for the duration of that function’s
execution. Once makeFunc() has finished
executing, it is reasonable to expect that the
name variable will no longer be necessary.
Since the code still works as expected, this is
obviously not the case.
43. 43
WorkingwithClosures(cont.)
A closure is a special kind of object that combines
two things: a function, and the environment in
which that function was created.
The environment consists of any local variables that
were in-scope at the time that the closure was
created.
In this case, myFunc is a closure that incorporates
both the displayName() and the “Mozilla” string
that existed when the closure was created.
45. 45
AMoreInterestingExample(cont.)
We have defined a function makeAdder(x) which takes a
single argument x and returns a new function.The function
it returns takes a single argument y, and returns the sum of
x and y.
In essence, makeAdder is a function factory – it creates
functions which can add a specific value to their argument.
• add5 and add10 are both closures.They share the same
function body definition, but store different environments.
In add5’s environment, x is 5. In add10’s environment, x is
10.
47. Class-Basedvs.Prototype-Based
Languages
Class-Based Prototype-Based
Class and instance are
distinct entities.
Define a class with a class
definition; instantiate a
class with constructor
methods.
Create a single object with
new operator.
All objects are instances.
Define and create a set of
objects with constructor
functions.
Same.
48. Class-Basedvs.Prototype-Based
Languages(cont.)
Construct an object
hierarchy by using class
definitions to define
subclasses of existing
classes.
Inherit properties by
following the class chain.
Class definition specifies all
properties of all instances
of a class. Cannot add
properties dynamically at
run time.
Construct an object
hierarchy by assigning an
object as the prototype
associated with a
constructor function.
Inherit properties by
following the prototype
chain.
Constructor function or
prototype specifies an
initial set of properties. Can
add or remove properties
dynamically to individual
objects or to the entire set
of objects.
50. 50
PublicMembers
All of the class’s attributes and methods are
public and accessible.The public attributes are
created using the this keyword.
There are two main ways of putting members in
a new object:
In the constructor
In the prototype
51. 51
Intheconstructor
This technique is usually used to initialize public instance
variables.The constructor’s this variable is used to add
members to the object.
function Container(param) {
this.member = param;
}
So, if we construct a new object
var myContainer = new Container(„abc‟);
then
myContainer.member contains „abc‟.
52. 52
Intheprototype
This technique is usually used to add public
methods.
To add a method to all objects made by a
constructor, add a function to the constructor’s
prototype:
Container.prototype.stamp = function(string) {
return this.member + string;
}
myContainer.stamp(„def‟); //‟abcdef‟
53. 53
PrivateMembersUsingaNaming
Convention
An underscore is added to the beginning of each
member, signifying that it is intended to be
private.
Using an underscore is a well-known naming
convention; it says that the attribute (or
method) is used internally, and that accessing it
or setting it directly may have unintended
consequences.
54. 54
PrivateMembersThroughClosures
Private members are made by the constructor.
Ordinary vars and parameters of the
constructor becomes the private members.
By convention, we make a private that
parameter.This is used to make the object
available to the private methods.
Private methods cannot be called by public
methods.
56. 56
PrivilegedMembers
A privileged method is able to access the private
variables and methods, and is itself accessible to
public methods and the outside.
58. 58
StaticMembers
Static members operate on the class-level instead
of the instance-level; there is only one copy of each
static member.
These private static members can be accessed from
within the constructor, which means that any
private or privileged function has access to them.
Since they are declared outside of the constructor,
they do not have access to any of the private
attributes, and as such, are not privileged; private
methods can call private static methods, but not the
other way around.
59. 59
var Book = (function() {
var numOfBooks = 0; // Private static attributes.
function checkIsbn(isbn) { // Private static method.
...
}
// Return the constructor.
return function(newIsbn, newTitle, newAuthor) {
var isbn; // Private attributes.
this.getIsbn = function() { // Privileged methods.
return isbn;
};
this.setIsbn = function(newIsbn) {
if(!checkIsbn(newIsbn)) throw new Error('Book: Invalid ISBN.');
isbn = newIsbn;
};
numOfBooks++; // Keep track of how many Books have been created
this.setIsbn(newIsbn);
}
})();
Book.convertToTitleCase = function(inputString) { // Public static method.
...
};
Book.prototype = { // Public, non-privileged methods.
display: function() {
...
}
};
60. 60
AShortSummary
Private and Privileged members can only be made
when an object is constructed.
Public members can be added at any time.
Having too many privileged methods can cause
memory problems because new copies of all
privileged methods are created for each instance.
In the public members pattern, all methods are
created off of the prototype, which means there is
only one copy of each in memory, no matter how
many instances you create.
64. 64
Howdoesitwork?
Suppose you create the mark object:
var mark = new WorkerBee();
When JavaScript sees the new operator, it creates
a new generic object and passes this new object as
the value of the this keyword to theWorkerBee
constructor function.
Then sets the value of WorkerBee.prototype
to an object of Employee to setup prototype chain.
65. 65
LocalversusInheritedValues
When you access an object property, JavaScript
performs these steps:
1. Check to see if the value exists locally. If it does, return
that value.
2. If there is not a local value, check the prototype chain.
3. If an object in the prototype chain has a value for the
specified property, return that value.
4. If no such property is found, the object does not have
the property.
66. 66
Doesitwork?
Suppose you create amy instance.
var amy = new WorkerBee();
amy.name = “”;
amy.dept = “general”;
amy.projects = [];
Now, suppose you change the value of the name
property in the prototype associated with
Employee.
Employee.prototype.name = “Unknown”;
67. 67
Doesitwork?(cont.)
If you want to have default values for object properties and you want to
be able to change the default values at run time, you should set the
properties in the constructor’s prototype, not in the constructor function
itself.
function Employee() {
this.dept = “general”;
}
Employee.prototype.name = “”;
function WorkerBee() {
this.projects = [];
}
WorkerBee.prototype = new Employee();
amy = new WorkerBee();
Employee.prototype.name = “Unknown”;
68. 68
AddingProperties
In JavaScript, you can add properties to any
object at run time.
To add a property that is specific to a single
object, you assign a value to the object.
mark.bonus = 3000;
Now, the mark object has a bonus property, but
no other WorkerBee has this property.
69. 69
AddingProperties(cont.)
If you add a new property to an object that is
being used as the prototype for a constructor
function, you add that property to all objects
that inherit properties from the prototype.
Employee.prototype.specialty = “none”;
73. ACleanerApproach
Another way of inheriting is by using
the .call/.apply methods. Below are
equivalent:
Using the javascript .call method makes a
cleaner implementation because the ".base"
is not needed anymore.
74. 74
Don’tsupposeitwillwork
Just because you have called the WorkerBee
constructor from inside the Engineering
constructor, you have set up inheritance
appropriately for Engineer object.This is not the
case.
Calling the WorkerBee constructor ensures that
an Engineer object starts out with the properties
specified in all constructor functions that are called.
If you later add properties to the Employee or
WorkerBee prototypes, those properties are not
inherited by the Engineer object.
75. 75
Don’tsupposeitwillwork(cont.)
function Enginner(name, projs, mach) {
WorkerBee.call(this, name, “engineering”, projs);
this.match = mach || “”;
}
var jane = new Engineer(“Doe, Jane”, [“navigator”,
“javascript”], “belau”);
Employee.prototype.specialty = “none”;
The jane object does not inherit the specialty
property.You still need to explicitly set up the
prototype to ensure dynamic inheritance.
76. 76
NoMultipleInheritance
JavaScript does not support multiple
inheritance.
Because an object has a single associated
prototype, JavaScript cannot dynamically inherit
from more than one prototype chain.
In JavaScript, you can have a constructor
function call more than one other constructor
function within it.
77. 77
NoMultipleInheritance(cont.)
function Hobbyist(hobby) {
this.hobby = hobby || “scuba”;
}
function Engineer(name, projs, mach, hobby) {
WorkerBee.call(this, name, “engineering”, projs);
Hobbyist.call(this, hobby);
this.machine = mach || “”;
}
Engineer.prototype = new WorkerBee();
dennis = new Engineer(“Doe Dennis”, [“collabra”], “hugo”);
78. 78
NoMultipleInheritance(cont.)
Assume, you then add a property to the Hobbyist
constructor’s prototype.
Hobbyist.prototype.equipment = [“mask”, “fins”,
“regulator”, “bcd”];
The dennis object does not inherit this new property.
79. 79
PatternsSummary
Public
function Constructor(…) {
this.membername = value;
}
Constructor.prototype.membername = value;
Private
function Constructor(…) {
var that = this;
var membername = value;
function membername(…) {…}
}
80. 80
PatternsSummary(cont.)
Privileged
function Constructor(…) {
this.membername = function(…) {…};
}
Inheritance
var SuperClass = function(…) {
this.superclassmember = value;
};
var SubClass = function(…) {
SuperClass.call(this, params);
this.subclassmember = value;
};
SubClass.prototype = new SuperClass();
82. 82
Practicalclosures
A closure lets you associate some data
(environment) with a function that operates on
that data.
You can use a closure anywhere that you might
normally use an object with only a single
method.
83. 83
Example1:FactoryMethod
Suppose, we wish to add to a page buttons that
adjust the size of the page text.
function size12() {
document.body.style.fontSize = “12px”;
}
function size14() {
document.body.style.fontSize = “14px”;
}
function size16() {
document.body.style.fontSize = “16px”;
}
84. 84
Example1:FactoryMethod(cont.)
Now, one could imagine that you would want to
generalize this notion of an “size function”, and you
would not want to write dozens and dozens of size
functions.
function makeSizer(size) {
return function() {
document.body.style.fontSize = size + “px”;
}
}
var size12 = makeSize(12);
var size14 = makeSize(14);
var size16 = makeSize(16);
86. 86
Example2:Emulatingprivatemethods
withclosures
The shared environment is created in the body
of an anonymous function, which is executed as
soon as it has been defined.
The environment contains two private items: a
variable called privateCounter and a function
called changeBy.
Neither of these private items can be accessed
directly from outside the anonymous function.
90. 90
Explanation
The reason for this is the functions assigned to
onfocus are closures; they consist of the function
definition and the captured environment from the
setupHelp function’s scope.
Three closures have been created, but each one
shares the same single environment.
By the time the onfocus callbacks are executed, the
loop has run its course and the item variable (shared
by all three closures) has been left pointing to the
last entry in the helpText list.
92. UsingAnonymousFunctionstoInduce
theScope
// Iterate through each of the items
for ( var i = 0; i < helpText.length; i++ ) {
// Use a self-executed anonymous function to induce scope
(function(){
// Remember the value within this scope
var item = helpText[i];
// Bind a function to the element
document.getElementById(item).onfocus = function() {
// item refers to a parent variable
// scoped within the context of this for loop
document.getElementById(„help‟).innerHTML = item.help;
};
})();
}
93. 93
Example5:setTimeoutwithFunction
References
A common use for a closure is to provide
parameters for the execution of a function prior to
the execution of that function.
The problem is that the function that passes to
setTimeout cannot provide parameters.
However, code could call another function that
returned a reference to an inner function object,
with that inner function object being passed by
reference to the setTimeout function.The
parameters to be used for the execution of the inner
function are passed with the call to the function that
returns it.
95. Example6:UsingAnonymousFunctionsto
HideVariablesfromtheGlobalScope
// Create a new anonymous function, to use as a wrapper
(function(){
// The variable that would, normally, be global
var msg = "Thanks for visiting!";
// Binding a new function to a global object
window.onunload = function(){
// Which uses the 'hidden' variable
alert( msg );
};
// Close off the anonymous function and execute it
})();
96. 96
Example7:AssociatingFunctionswith
ObjectInstanceMethods
You want to associate different functions to each
event handler.
Don’t put associateObjWithEvent() inside the
DhtmlObject constructor function. See
Accidental Closures and Performance
considerations for more details.
98. 98
Example8:EncapsulatingRelated
Functionality
The array is going to act as a buffer for the output, but defining it
locally to the function will result in its re-creation on each
execution of the function.
One approach might make the array a global variable so that it
can be re-used without being re-created. But the effect is to
render the code less manageable, as, if it is to be used elsewhere.
It also makes the code less easy to integrate with other code
because it pollutes the global namespace.
A Closure allows the buffer array to be associated (and neatly
packaged) with the function that is dependent upon it and
simultaneously keep the property name to which the buffer array
as assigned out of the global namespace and free of the risk of
name conflicts and accidental interactions.
99. var getImgInPositionedDivHtml = (function(){
var buffAr = [
'<div id="', '', // index 1, DIV ID attribute
'" style="position:absolute;top:', '', // index 3, DIV top position
'px;left:', '', // index 5, DIV left position
'px;width:', '', // index 7, DIV width
'px;height:','', // index 9, DIV height
'px;overflow:hidden;"><img src="', '', // index 11, IMG URL
'" width="', '', // index 13, IMG width
'" height="', '', // index 15, IMG height
'" alt="', '', // index 17, IMG alt text
'"></div>'
];
return function(url, id, width, height, top, left, altText){
buffAr[1] = id; buffAr[3] = top;
buffAr[5] = left;
buffAr[13] = (buffAr[7] = width);
buffAr[15] = (buffAr[9] = height);
buffAr[11] = url; buffAr[17] = altText;
return buffAr.join('');
}; //:End of inner function expression.
})();
100. 100
Example8:EncapsulatingRelated
Functionality
The array is going to act as a buffer for the output, but defining it
locally to the function will result in its re-creation on each
execution of the function.
One approach might make the array a global variable so that it
can be re-used without being re-created. But the effect is to
render the code less manageable. It also makes the code less
easy to integrate with other code because it pollutes the global
namespace.
A Closure allows the buffer array to be associated (and neatly
packaged) with the function that is dependent upon it and
simultaneously keep the property name to which the buffer array
as assigned out of the global namespace and free of the risk of
name conflicts and accidental interactions.
101. AccidentalClosures
Rendering any inner function accessible
outside of the body of the function in which it
was created will form a closure.
Accidentally creating closures can have
harmful side effects as the following section
on the IE memory leak problem describes.
A common situation is where inner functions
are used is as event handlers for DOM
elements.
102. AccidentalClosures(cont.)
var quantaty = 5;
function addGlobalQueryOnClick(linkRef){
if(linkRef){
linkRef.onclick = function(){
this.href += ('?quantaty='+escape(quantaty));
return true;
};
}
}
Whenever the addGlobalQueryOnClick function is called a new inner function is
created (and a closure formed by its assignment).
From the efficiency point of view that would not be significant if the
addGlobalQueryOnClick function was only called once or twice, but if the function
was heavily employed many distinct function objects would be created (one for each
evaluation of the inner function expression).
103. AccidentalClosures(cont.)
As the inner function in the first version is not being used to
exploit the closures produced by its use, it would be more
efficient not to use an inner function, and thus not repeat
the process of creating many essentially identical function
objects.
var quantaty = 5;
function addGlobalQueryOnClick(linkRef){
if(linkRef){
linkRef.onclick = forAddQueryOnClick;
}
}
function forAddQueryOnClick(){
this.href += ('?quantaty='+escape(quantaty));
return true;
}