The document provides an overview of object-oriented programming concepts in JavaScript, including:
- JavaScript uses prototype-based inheritance rather than classes, with functions serving as constructors.
- Objects inherit properties and methods from other objects via their prototype chain.
- Custom objects are defined with constructor functions that set properties and methods.
- Inheritance allows creating subclasses that inherit from superclasses. Methods can be overridden.
- Encapsulation involves exposing an object's data through getter/setter methods rather than direct access.
- Superclass members can be accessed in subclasses through calling the superclass constructor or methods.
- Constructor arguments are passed to subclasses by applying the superclass constructor.
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
JavaScript Module Patterns: How to build and use JavaScript modules. We cover the Basic Module Pattern, Revealing Module Pattern, CommonJS, AMD, CommonJS, UMD and ES6 modules.
The Browser Object Model (BOM) in JavaScript includes the properties and methods for JavaScript to interact with the web browser.
BOM provides you with window object, for example, to show the width and height of the window. It also includes the window.screen object to show the width and height of the screen.
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
JavaScript Module Patterns: How to build and use JavaScript modules. We cover the Basic Module Pattern, Revealing Module Pattern, CommonJS, AMD, CommonJS, UMD and ES6 modules.
The Browser Object Model (BOM) in JavaScript includes the properties and methods for JavaScript to interact with the web browser.
BOM provides you with window object, for example, to show the width and height of the window. It also includes the window.screen object to show the width and height of the screen.
Getting started with the reactjs, basics of reactjs, introduction of reactjs, core concepts of reactjs and comparison with the other libraries/frameworks
A presentation of what are JavaScript Promises, what problems they solve and how to use them. Dissects some Bluebird features, the most complete Promise library available for NodeJS and browser.
JavaScript has some stunning features like Closures, Prototype etc. which can help to improve the readability and maintainability of the code. However, it is not easy for inexperienced developer to consume and apply those features in day to day coding. The purpose of the presentation ‘Advanced JavaScript’ is to help a reader easily understand the concept and implementation of some advanced JavaScript features.
What is JavaScript?
JavaScript is a very powerful client-side scripting language. JavaScript is used mainly for enhancing the interaction of a user with the webpage. In other words, you can make your webpage more lively and interactive, with the help of JavaScript. JavaScript is also being used widely in game development and Mobile application development.
안드로이드 웹뷰의 모든것
이형욱
NAVER / Whale Core
웨일 브라우저 TL로 웨일 브라우저 개발 및 관련 기술을 연구하고 있습니다. 웹엔진 (WebKit, Blink) 오픈소스 활동을 하고 있으며, 현재 브라우저 렌더링 성능 및 메모리 최적화에 관심이 있습니다.
Tutorial Videos: https://www.youtube.com/playlist?list=PLD8nQCAhR3tQ7KXnvIk_v_SLK-Fb2y_k_
Day 1 : Introduction to React, Babel and Webpack
Prerequisites of starting the workshop ( Basic understanding of Node & Express )
What is Virtual DOM?
What is React and why should we use it?
Install and set up React:
a-Using create-react-app
b-From scratch using Babel and Webpack. We will use Webpack Dev Server.
Day 2 : React Basic Concepts
Types of Components: Class-based and Functional based Components
Use of JSX
Parent, Child, and Nested Components
Difference between State and Props
Create and Handle Routes
Component Lifecycle Methods
Create a form and handling form inputs
Use of arrow functions and Spread Operator
Day 3: Advanced Concepts in React
Use of Refs
What are Higher Order Components( HOC )?
How to use HOC
Understanding Context in React
YouTube Link: https://youtu.be/Ia0FSogTRaw
** Full Stack Web Development Training: https://www.edureka.co/masters-program/full-stack-developer-training **
This Edureka PPT on What is JavaScript explains all the fundamentals of JavaScript with examples. It also explains various features and applications of JavaScript in the following sequence:
Origin of JavaScript
What is JavaScript?
What can JavaScript do?
JavaScript Frameworks
HTML vs CSS vs JavaScript
Benefits of JavaScript
JavaScript Fundamentals
Follow us to never miss an update in the future.
YouTube: https://www.youtube.com/user/edurekaIN
Instagram: https://www.instagram.com/edureka_learning/
Facebook: https://www.facebook.com/edurekaIN/
Twitter: https://twitter.com/edurekain
LinkedIn: https://www.linkedin.com/company/edureka
Castbox: https://castbox.fm/networks/505?country=in
Getting started with the reactjs, basics of reactjs, introduction of reactjs, core concepts of reactjs and comparison with the other libraries/frameworks
A presentation of what are JavaScript Promises, what problems they solve and how to use them. Dissects some Bluebird features, the most complete Promise library available for NodeJS and browser.
JavaScript has some stunning features like Closures, Prototype etc. which can help to improve the readability and maintainability of the code. However, it is not easy for inexperienced developer to consume and apply those features in day to day coding. The purpose of the presentation ‘Advanced JavaScript’ is to help a reader easily understand the concept and implementation of some advanced JavaScript features.
What is JavaScript?
JavaScript is a very powerful client-side scripting language. JavaScript is used mainly for enhancing the interaction of a user with the webpage. In other words, you can make your webpage more lively and interactive, with the help of JavaScript. JavaScript is also being used widely in game development and Mobile application development.
안드로이드 웹뷰의 모든것
이형욱
NAVER / Whale Core
웨일 브라우저 TL로 웨일 브라우저 개발 및 관련 기술을 연구하고 있습니다. 웹엔진 (WebKit, Blink) 오픈소스 활동을 하고 있으며, 현재 브라우저 렌더링 성능 및 메모리 최적화에 관심이 있습니다.
Tutorial Videos: https://www.youtube.com/playlist?list=PLD8nQCAhR3tQ7KXnvIk_v_SLK-Fb2y_k_
Day 1 : Introduction to React, Babel and Webpack
Prerequisites of starting the workshop ( Basic understanding of Node & Express )
What is Virtual DOM?
What is React and why should we use it?
Install and set up React:
a-Using create-react-app
b-From scratch using Babel and Webpack. We will use Webpack Dev Server.
Day 2 : React Basic Concepts
Types of Components: Class-based and Functional based Components
Use of JSX
Parent, Child, and Nested Components
Difference between State and Props
Create and Handle Routes
Component Lifecycle Methods
Create a form and handling form inputs
Use of arrow functions and Spread Operator
Day 3: Advanced Concepts in React
Use of Refs
What are Higher Order Components( HOC )?
How to use HOC
Understanding Context in React
YouTube Link: https://youtu.be/Ia0FSogTRaw
** Full Stack Web Development Training: https://www.edureka.co/masters-program/full-stack-developer-training **
This Edureka PPT on What is JavaScript explains all the fundamentals of JavaScript with examples. It also explains various features and applications of JavaScript in the following sequence:
Origin of JavaScript
What is JavaScript?
What can JavaScript do?
JavaScript Frameworks
HTML vs CSS vs JavaScript
Benefits of JavaScript
JavaScript Fundamentals
Follow us to never miss an update in the future.
YouTube: https://www.youtube.com/user/edurekaIN
Instagram: https://www.instagram.com/edureka_learning/
Facebook: https://www.facebook.com/edurekaIN/
Twitter: https://twitter.com/edurekain
LinkedIn: https://www.linkedin.com/company/edureka
Castbox: https://castbox.fm/networks/505?country=in
Prototype-based Programming with JavaScriptlienhard
This are the slides from a 2 hour lecture introducing object-oriented prototype-based programming. It includes an introduction to JavaScript, delegation, constructors, and closures.
CSS Sanity with Sass: The Inverted Triangle ApproachJulie Kuehl
You always start with the best of intentions. The parent/starter theme you begin your custom site with has a beautifully laid out style.css file. You do your best to keep everything organized and logical, but in the throes of deadlines and CSS frustrations things get ugly. Maybe you’ve heard of Sass and don’t know how to begin. Maybe you’ve used Sass and aren’t quite seeing the light yet. We’ll go over how to begin with Sass and how to use the Inverted Triangle way of organizing Sass to help you keep your sanity throughout the entire project.
View, Act, and React: Shaping Business Activity with Analytics, BigData Queri...Srinath Perera
Sun Tzu said “if you know your enemies and know yourself, you can win a hundred battles without a single loss.” Those words have never been truer than in our time. We are faced with an avalanche of data. Many believe the ability to process and gain insights from a vast array of available data will be the primary competitive advantage for organizations in the years to come.
To make sense of data, you will have to face many challenges: how to collect, how to store, how to process, and how to react fast. Although you can build these systems from bottom up, it is a significant problem. There are many technologies, both open source and proprietary, that you can put together to build your analytics solution, which will likely save you effort and provide a better solution.
In this session, Srinath will discuss WSO2’s middleware offering in BigData and explain how you can put them together to build a solution that will make sense of your data. The session will cover technologies like thrift for collecting data, Cassandra for storing data, Hadoop for analyzing data in batch mode, and Complex event processing for analyzing data real time.
Best practices when starting with Sass. Debunked myth that Sass is a new syntax everyone should noe embrace and recode everything in it. Sass brings to CSS many super useful features but the benefits can only be reaped if you apply sensible approaches. Otherwise you risk making things worse than using plain old CSS.
From this presentation, we will understand,
- Introduction to Sass
- Why adding Sass in our workflow
- Advantages of Sass
- How to convert our CSS into Sass
- Compass
- What is Compass
- How to use sass with compass
Understanding Object Oriented Javascript - Coffee@DBG JuneDeepu S Nath
You all might have downloaded and edited a lot of javascript. Other than merely changing syntax have you really understood its working or how the code was organised ?
Have you ever thought of how the object oriented way of writing Javascript has been influencing the front end development?
From a language that had helped developers write small validations and similar stuff, today, the object oriented javascript and its frameworks power the world becoming one of the most prominent language of all times.
Enhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdfJay Das
With the advent of artificial intelligence or AI tools, project management processes are undergoing a transformative shift. By using tools like ChatGPT, and Bard organizations can empower their leaders and managers to plan, execute, and monitor projects more effectively.
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...informapgpstrackings
Keep tabs on your field staff effortlessly with Informap Technology Centre LLC. Real-time tracking, task assignment, and smart features for efficient management. Request a live demo today!
For more details, visit us : https://informapuae.com/field-staff-tracking/
Large Language Models and the End of ProgrammingMatt Welsh
Talk by Matt Welsh at Craft Conference 2024 on the impact that Large Language Models will have on the future of software development. In this talk, I discuss the ways in which LLMs will impact the software industry, from replacing human software developers with AI, to replacing conventional software with models that perform reasoning, computation, and problem-solving.
In software engineering, the right architecture is essential for robust, scalable platforms. Wix has undergone a pivotal shift from event sourcing to a CRUD-based model for its microservices. This talk will chart the course of this pivotal journey.
Event sourcing, which records state changes as immutable events, provided robust auditing and "time travel" debugging for Wix Stores' microservices. Despite its benefits, the complexity it introduced in state management slowed development. Wix responded by adopting a simpler, unified CRUD model. This talk will explore the challenges of event sourcing and the advantages of Wix's new "CRUD on steroids" approach, which streamlines API integration and domain event management while preserving data integrity and system resilience.
Participants will gain valuable insights into Wix's strategies for ensuring atomicity in database updates and event production, as well as caching, materialization, and performance optimization techniques within a distributed system.
Join us to discover how Wix has mastered the art of balancing simplicity and extensibility, and learn how the re-adoption of the modest CRUD has turbocharged their development velocity, resilience, and scalability in a high-growth environment.
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...Globus
Large Language Models (LLMs) are currently the center of attention in the tech world, particularly for their potential to advance research. In this presentation, we'll explore a straightforward and effective method for quickly initiating inference runs on supercomputers using the vLLM tool with Globus Compute, specifically on the Polaris system at ALCF. We'll begin by briefly discussing the popularity and applications of LLMs in various fields. Following this, we will introduce the vLLM tool, and explain how it integrates with Globus Compute to efficiently manage LLM operations on Polaris. Attendees will learn the practical aspects of setting up and remotely triggering LLMs from local machines, focusing on ease of use and efficiency. This talk is ideal for researchers and practitioners looking to leverage the power of LLMs in their work, offering a clear guide to harnessing supercomputing resources for quick and effective LLM inference.
SOCRadar Research Team: Latest Activities of IntelBrokerSOCRadar
The European Union Agency for Law Enforcement Cooperation (Europol) has suffered an alleged data breach after a notorious threat actor claimed to have exfiltrated data from its systems. Infamous data leaker IntelBroker posted on the even more infamous BreachForums hacking forum, saying that Europol suffered a data breach this month.
The alleged breach affected Europol agencies CCSE, EC3, Europol Platform for Experts, Law Enforcement Forum, and SIRIUS. Infiltration of these entities can disrupt ongoing investigations and compromise sensitive intelligence shared among international law enforcement agencies.
However, this is neither the first nor the last activity of IntekBroker. We have compiled for you what happened in the last few days. To track such hacker activities on dark web sources like hacker forums, private Telegram channels, and other hidden platforms where cyber threats often originate, you can check SOCRadar’s Dark Web News.
Stay Informed on Threat Actors’ Activity on the Dark Web with SOCRadar!
Enterprise Resource Planning System includes various modules that reduce any business's workload. Additionally, it organizes the workflows, which drives towards enhancing productivity. Here are a detailed explanation of the ERP modules. Going through the points will help you understand how the software is changing the work dynamics.
To know more details here: https://blogs.nyggs.com/nyggs/enterprise-resource-planning-erp-system-modules/
Understanding Globus Data Transfers with NetSageGlobus
NetSage is an open privacy-aware network measurement, analysis, and visualization service designed to help end-users visualize and reason about large data transfers. NetSage traditionally has used a combination of passive measurements, including SNMP and flow data, as well as active measurements, mainly perfSONAR, to provide longitudinal network performance data visualization. It has been deployed by dozens of networks world wide, and is supported domestically by the Engagement and Performance Operations Center (EPOC), NSF #2328479. We have recently expanded the NetSage data sources to include logs for Globus data transfers, following the same privacy-preserving approach as for Flow data. Using the logs for the Texas Advanced Computing Center (TACC) as an example, this talk will walk through several different example use cases that NetSage can answer, including: Who is using Globus to share data with my institution, and what kind of performance are they able to achieve? How many transfers has Globus supported for us? Which sites are we sharing the most data with, and how is that changing over time? How is my site using Globus to move data internally, and what kind of performance do we see for those transfers? What percentage of data transfers at my institution used Globus, and how did the overall data transfer performance compare to the Globus users?
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...Anthony Dahanne
Les Buildpacks existent depuis plus de 10 ans ! D’abord, ils étaient utilisés pour détecter et construire une application avant de la déployer sur certains PaaS. Ensuite, nous avons pu créer des images Docker (OCI) avec leur dernière génération, les Cloud Native Buildpacks (CNCF en incubation). Sont-ils une bonne alternative au Dockerfile ? Que sont les buildpacks Paketo ? Quelles communautés les soutiennent et comment ?
Venez le découvrir lors de cette session ignite
Enhancing Research Orchestration Capabilities at ORNL.pdfGlobus
Cross-facility research orchestration comes with ever-changing constraints regarding the availability and suitability of various compute and data resources. In short, a flexible data and processing fabric is needed to enable the dynamic redirection of data and compute tasks throughout the lifecycle of an experiment. In this talk, we illustrate how we easily leveraged Globus services to instrument the ACE research testbed at the Oak Ridge Leadership Computing Facility with flexible data and task orchestration capabilities.
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoamtakuyayamamoto1800
In this slide, we show the simulation example and the way to compile this solver.
In this solver, the Helmholtz equation can be solved by helmholtzFoam. Also, the Helmholtz equation with uniformly dispersed bubbles can be simulated by helmholtzBubbleFoam.
Into the Box Keynote Day 2: Unveiling amazing updates and announcements for modern CFML developers! Get ready for exciting releases and updates on Ortus tools and products. Stay tuned for cutting-edge innovations designed to boost your productivity.
AI Pilot Review: The World’s First Virtual Assistant Marketing SuiteGoogle
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
👉👉 Click Here To Get More Info 👇👇
https://sumonreview.com/ai-pilot-review/
AI Pilot Review: Key Features
✅Deploy AI expert bots in Any Niche With Just A Click
✅With one keyword, generate complete funnels, websites, landing pages, and more.
✅More than 85 AI features are included in the AI pilot.
✅No setup or configuration; use your voice (like Siri) to do whatever you want.
✅You Can Use AI Pilot To Create your version of AI Pilot And Charge People For It…
✅ZERO Manual Work With AI Pilot. Never write, Design, Or Code Again.
✅ZERO Limits On Features Or Usages
✅Use Our AI-powered Traffic To Get Hundreds Of Customers
✅No Complicated Setup: Get Up And Running In 2 Minutes
✅99.99% Up-Time Guaranteed
✅30 Days Money-Back Guarantee
✅ZERO Upfront Cost
See My Other Reviews Article:
(1) TubeTrivia AI Review: https://sumonreview.com/tubetrivia-ai-review
(2) SocioWave Review: https://sumonreview.com/sociowave-review
(3) AI Partner & Profit Review: https://sumonreview.com/ai-partner-profit-review
(4) AI Ebook Suite Review: https://sumonreview.com/ai-ebook-suite-review
Listen to the keynote address and hear about the latest developments from Rachana Ananthakrishnan and Ian Foster who review the updates to the Globus Platform and Service, and the relevance of Globus to the scientific community as an automation platform to accelerate scientific discovery.
2. OOP in JavaScript
• Overview
• Prototype Chain
• Custom Objects
o The class
o The constructor
o The object (class instance)
o The property
o The method
o Static members
o Private and privileged members
• Inheritance
• Encapsulation
• Accessing Superclass Members
• Passing Constructor Arguments
3. Overview
• JavaScript is designed on a simple object-based
paradigm. An object is a collection of properties,
and a property is an association between a name
and a value. A property's value can be a function,
in which case the property is known as a method.
• One of the key differences of JavaScript from other
OOP languages is that it does not have classes.
Instead, JavaScript uses functions as classes.
• The class functionality is accomplished by object
prototypes where object inherits from another
object.
4. Overview
• JavaScript functions are objects, giving functions the
capacity to hold executable code and be passed
around like any other object.
• All objects in JavaScript are descended from Object
object.
• All objects inherit methods and properties from
Object.prototype.
• All object properties/methods are public.
5. Prototype Chain
• A prototype chain is a finite chain of objects which is used
to implement inheritance and shared properties.
• Every object in JavaScript has an internal link to another
object called prototype. That prototype object has a
prototype of its own, and so on until an object is reached
with null as its prototype.
• __proto__ is the actual object that is used in the lookup
chain to resolve methods, etc.
• prototype is the object that is used to build __proto__ when
you create an object.
8. Custom Objects
• In JavaScript the function serves as the constructor
of the object.
• The constructor is used to set the object's properties
or to call methods to prepare the object for use.
function Person () {
console.log('instance created');
}
The constructor
9. Custom Objects
• An instance of an object can be created by
executing the constructor function using the new
operator.
var person1 = new Person();
var person2 = new Person();
The object (class instance)
10. Custom Objects
• Properties are set in the constructor of the class so
that they are created on each instance.
• The keyword this, which refers to the current object,
lets you work with properties from within the class.
The property (object attribute)
11. Custom Objects
function Person(firstName) {
this.firstName = firstName;
console.log('Person instantiated');
}
var person1 = new Person('Alice');
var person2 = new Person('Bob');
// Show the firstName properties of the objects
console.log('person1 is ' + person1.firstName); // logs "person1 is Alice"
console.log('person2 is ' + person2.firstName); // logs "person2 is Bob"
The property (object attribute)
12. Custom Objects
• Methods are functions that follow the same logic as
properties. Calling a method is similar to accessing a
property, but you add () at the end of the method
name, possibly with arguments.
• To define a method, assign a function to a named
property of the class's prototype property.
The method
13. Custom Objects
function Person(firstName) {
this.firstName = firstName;
}
Person.prototype.sayHello = function() {
console.log("Hello, I'm " + this.firstName);
};
var person1 = new Person("Alice");
var person2 = new Person("Bob");
// call the Person sayHello method.
person1.sayHello(); // logs "Hello, I'm Alice"
person2.sayHello(); // logs "Hello, I'm Bob"
The method
14. Custom Objects
• Static members (properties/methods) or class
members only exist on the class and doesn't exist on
child objects.
Static members
16. Custom Objects
• Private members are made by the constructor. Local
vars and parameters of the constructor becomes
the private members.
• A privileged method is able to access the private
variables and methods, and is itself accessible to the
public methods and the outside.
Private and privileged members
17. Custom Objects
function Person(firstName) {
//-- private
var _firstName = firstName;
function _getMessage() {
return "Hello my name is " + _firstName;
}
//-- privileged
this.sayHello = function() {
console.log(_getMessage());
}
}
var person1 = new Person("Alice");
person1. sayHello(); // logs "Hello my name is Alice"
Private and privileged members
18. Inheritance
• Inheritance is a way to create a class as a specialized
version of another class.
• JavaScript only supports single inheritance.
• When trying to access a property of an object, the
property will not only be sought on the object but on the
prototype of the object, the prototype of the prototype,
and so on until either a property with a matching name is
found or the end of the prototype chain is reached.
• When an inherited function is executed, the value of this
points to the inheriting object, not to the prototype
object where the function is an own property.
19. Inheritance
function Photo(name) {
this.name = name || "photo";
}
Photo.prototype.upload = function() {
console.log("Photo.upload:", this.name);
};
ProfilePhoto.prototype = Object.create(Photo.prototype);
function ProfilePhoto(name) {
Photo.call(this, name || "profile-photo");
}
var photo = new Photo();
photo.upload(); // logs "Photo.upload: photo"
var profilePhoto = new ProfilePhoto();
profilePhoto.upload(); // logs "Photo.upload: profile-photo"
20. Inheritance
function Photo(name) {
this.name = name || "photo";
}
Photo.prototype.upload = function() {
console.log("Photo.upload:", this.name);
};
ProfilePhoto.prototype = Object.create(Photo.prototype);
function ProfilePhoto(name) {
Photo.call(this, name || "profile-photo");
}
//-- method override
ProfilePhoto.prototype.upload = function() {
console.log("ProfilePhoto.upload:", this.name);
};
var photo = new Photo();
photo.upload(); // logs "Photo.upload: photo"
var profilePhoto = new ProfilePhoto();
profilePhoto.upload(); // logs "ProfilePhoto.upload: profile-photo"
21. Encapsulation
• Encapsulation includes the idea that the data of an
object should not be directly exposed.
• Instead, callers that want to achieve a given result
are coaxed into proper usage by invoking methods
(rather than accessing the data directly).
22. Encapsulation
function Photo(name) {
this.name = name || "photo";
}
Photo.prototype.setName = function(name) {
this.name = name;
};
Photo.prototype.getName = function() {
return this.name;
};
var photo = new Photo();
photo.setName("picture"); // sets photo name to "picture"
photo.getName(); // returns "picture"
23. Encapsulation
function Photo(name) {
var _name = name || "photo";
Object.defineProperty(this, "name", {
get: function() {
return _name;
},
set: function(name) {
_name = name;
}
});
}
var photo = new Photo();
photo.name = "picture"; // sets photo name to "picture"
photo.name; // returns “picture”
24. Accessing Superclass
Members
• One of the big differences between Classical
(Object-Oriented) and Prototypal inheritance is that
the former has an elegant mechanism for referring
to the parent class (usually using the super keyword).
It's often used in constructors to initialize the parent
class with the supplied input parameters. Another
common usage is to extend parent functionality in
the child class.
25. Accessing Superclass
Members
function Photo(name) {
var _name = name || "photo";
Object.defineProperty(this, "name", {
get: function() {
return _name;
}
});
}
Photo.prototype.upload = function() {
console.log("Photo.upload:", this.name);
};
26. Accessing Superclass
Members
ProfilePhoto.prototype = Object.create(Photo.prototype);
function ProfilePhoto(name) {
Photo.call(this, name || "profile-photo");
}
//-- method override
ProfilePhoto.prototype.upload = function() {
Photo.prototype.upload.call(this);
console.log(”ProfilePhoto.upload:", this.name);
};
var profilePhoto = new ProfilePhoto();
profilePhoto.upload();
// logs "Photo.upload: profile-photo"
// logs "ProfilePhoto.upload: profile-photo"
27. Accessing Superclass
Members
ProfilePhoto.prototype = Object.create(Photo.prototype);
function ProfilePhoto(name) {
Object.defineProperty(this, "parent", {
get: function() {
return Photo;
}
});
this.parent.call(this, name || "profile-photo");
}
//-- method override
ProfilePhoto.prototype.upload = function() {
this.parent.prototype.upload.call(this);
console.log(”ProfilePhoto.upload:", this.name);
};
var profilePhoto = new ProfilePhoto();
profilePhoto.upload();
// logs "Photo.upload: profile-photo"
// logs "ProfilePhoto.upload: profile-photo"
28. Passing Constructor
Arguments
function Photo(name) {
var _name = name || "photo";
Object.defineProperty(this, "name", {
get: function() {
return _name;
}
});
}
ProfilePhoto.prototype = Object.create(Photo.prototype);
function ProfilePhoto() {
Photo.apply(this, Array.prototype.slice.call(arguments));
}
var profilePhoto = new ProfilePhoto("avatar"); // sets the name to "avatar"