Link for all dot net and sql server video tutorial playlists
http://www.youtube.com/user/kudvenkat...
Link for slides, code samples and text version of the video
http://csharp-video-tutorials.blogspo...
In this video we will discuss, object reflection in JavaScript with an example.
Object oriented programming languages like C# and Java, support reflection. Reflection allows us to inspect meta data of assemblies, modules and types. Since JavaScript is also an object oriented programming language, it also supports the concept of reflection. Let's understand Object reflection in JavaScript with an example.
Employee object in the following example has 4 public properties
1. firstName
2. lastName
3. email
4. gender
and 3 public functions
1. getFullName
2. getEmail
3. getGender
var Employee = function (firstName, lastName, gender, email)
{ this.firstName = firstName; this.lastName = lastName; this.gender = gender; this.email = email;
}
Employee.prototype.getFullName = function ()
{ return this.firstName + " " + this.lastName;
}
Employee.prototype.getEmail = function ()
{ return this.email;
}
Employee.prototype.getGender = function ()
{ return this.gender;
}
var employee = new Employee("Mark", "Matt", "Male", "a@a.com");
The following code retrieves all the public properties and methods of the Employee object.
for (var property in employee)
{ document.write(property + "[br/]");
}
Output :
firstName
lastName
gender
getFullName
getEmail
getGender
The following code retrieves all the public properties & functions of the Employee object along with their values.
for (var property in employee)
{ document.write(property + " : " + employee[property] + "[br/]");
}
Output :
firstName : Mark
lastName : Matt
gender : Male
email : a@a.com
getFullName : function () { return this.firstName + " " + this.lastName; }
getEmail : function () { return this.email; }
getGender : function () { return this.gender; }
The following code retrieves only the public properties of the Employee object.
for (var property in employee)
{ if (typeof employee[property] != "function") { document.write(property + " : " + employee[property] + "[br/]"); }
}
Output:
firstName : Mark
lastName : Matt
gender : Male
email : a@a.com
The following code retrieves only the public functions of the Employee object.
for (var property in employee)
{ if (typeof employee[property] == "function") { document.write(property + " : " + employee[property] + "[br/]"); }
}
Output :
getFullName : function () { return this.firstName + " " + this.lastName; }
getEmail : function () { return this.email; }
getGender : function () { return this.gender; }
When 2 objects are related thru inheritance, the child object will have access to parent object methods and properties. In this example, PermanentEmployee is a child of Employee. The following code shows all the properties and methods of the PermanentEmployee object including those it inherited from the Employee object.
var employee = new Employee("Mark", "Matt", "Male", "a@a.com");
var PermanentEmployee = function (annualSalry)
{ this.annualSalary = annualSalry;
}
PermanentEmployee.prototype = employee;
var pe = new PermanentEmployee(50000);
for (var property in pe)
{ document.write(property + " : " + pe[property] + "[br/]");
}
Output :
annualSalary : 50000
firstName : Mark
lastName : Matt
gender : Male
email : a@a.com
getFullName : function () { return this.firstName + " " + this.lastName; }
getEmail : function () { return this.email; }
getGender : function () { return this.gender; }
In this example, we are using hasOwnProperty() method to determine if a property is defined on the actual object or it's prototype. This method returns true if the property is defined by the object itself, otherwise false. The following code retrieves only the public members that are defined in the PermanentEmployee object. The members inherited from the base Employee object are excluded.
for (var property in pe)
{ if (pe.hasOwnProperty(property)) { document.write(property + " : " + pe[property] + "[br/]"); }
}
Output : annualSalary : 50000
The following code retrieves only the public members inherited from the parent object. Public members defined in PermanentEmployee object are excluded.
for (var property in pe)
{ if (!pe.hasOwnProperty(property)) { document.write(property + " : " + pe[property] + "[br/]"); }
}
Output :
firstName : Mark
lastName : Matt
gender : Male
email : a@a.com
getFullName : function () { return this.firstName + " " + this.lastName; }
getEmail : function () { return this.email; }
getGender : function () { return this.gender; }
asp.net core docker Object reflection in JavaScript | |
| 128 Likes | 128 Dislikes |
| 28,635 views views | 524K followers |
| Education | Upload TimePublished on 15 Feb 2015 |
Related keywords
wcf vs web api,ado.net core,sql server management studio,webkinz,webadvisor,craigslist nj,wcf one piece,asp.net core 3,ajax players,weber grill parts,webtoon,tutorials by hugo,csharp corner,mvc design pattern,asp.net machine account,servers for minecraft,asp.net core dependency injection,ado.net tutorial,services angular,ajax ontario,asp.net mvc tutorial,javascript tutorial date,asp.net cos'è,csharp assembly,javascript tutorialspoint,tutorialspoint python,sql join,services briefcase,asp.net core web api,ajax jquery,wccftech,craigslist ny,asp.net zero,csharp foreach,server memes,sql date format,javascript tutorial example,services online,chase,javascript tutorial callback,serverless architecture,server resume,wcf c#,server books,tutorialspoint javascript,mvcc connect,ado.net mysql,services technologies gps,javascript tutorial indonesia pdf,ajax deadpool,server jobs,cvs,website,mvc tutorial,costco hours,wcf service application,tutorialspoint spring,serverless,wcf soap,javascript tutorial code,wcf cat,wcf test client,cool math games,services & training hse colombia sas,servicestack,citibank,asp.net core identity,sql union,ajax parking,sql database,asp.net core logging,mvconnect,asp.net guida,cunyfirst,wcf nba,csharp download,wcfi foundation,csharp online,wcf authentication,javascript tutorial pdf,tutorials near me,http://asp.net,server 2019,ado.net descargar,web of dreams,chernobyl,serverminer,ajax cleaner,ado.net visual studio 2019,webassign,ado.net vs entity framework,ado.net visual studio 2017,csharp list,sql like,asp.net mvc,asp.net core tutorial,sqlite,wcfm,ajax roster,mvc architecture,http://ado.net,asp.net core mvc,ajax soccer,server hosting,wcfi,ajax dish soap,capital one,server rack,tutorialspoint html,csharp interface,craigslist,webroot,tutorialspoint reactjs,ajax request,wcf dragon ball,asp.net core 2.2,tutorialspoint python 3,sql developer,webster,services transmission company sas,sql group by,asp.net core signalr,services manager,mvc framework,ajax paving,mvc near me,tutorialspoint spring boot,mvc map,csharp online compiler,asp.net download,sql between,ado.net c# pdf,wcf 2019 nba,javascript tutorial download,services tag dell,csharp switch,ado.net ventajas y desventajas,csharpstar,wcf tutorial,javascript tutorial web development,tutorialspoint,ajax meaning,csharp-video-tutorials.blogspot,tutorials dojo,csharp string format,central park 5,ado.net c#,javascript tutorial for beginners,asp.net core github,server status,ajax fc,server jobs nyc,asp.net core swagger,sql formatter,credit karma,services group,server error in '/' application,services windows,asp.net core 3.0,sql injection,wcf ria services,tutorialspoint c#,calculator,ado.net entity data model,sql insert,tutorialspoint tableau,services google play apk,sqlyog,asp.net core 3 release date,sql server,server job description,tutorials by a,servicenow,webcam,mvc hours,javascript tutorial library,webmd symptom,csharp array,javascript tutorial w3,csharp enum,ajax call,asp.net core 2. guida completa per lo sviluppatore,asp.net core,server pro,server status ffxiv,webcrims,cheap flights,asp.net core hosting,services sas,javascript tutorial documentation,tutorialspoint java,tutorialspoint java compiler,webmd,csharp to json,college football,ado.net dataset,csharp dictionary,cnn,website builder,tutorialspoint sql,asp.net web api,server side rendering,weber grills,sql server 2017,mvc nj,tutorialspoint spark,javascript tutorial function,ado.net oracle,asp.net core download,csharp to vb.net,webster bank,webstaurant,tutorialsystems,ajax post,services fms publish announcement,services.msc no abre,ajax jersey,csharp operator,asp.net core razor pages,server duties,asp.net core environment variables,csharp random,century 21,services consultores,services consulting,mvcsd,mvcsc,services.msc,ado.net pdf,asp.net core configuration,ajax marvel,sql update,asp.net tutorial,mvc medical,ado.net entity data model visual studio 2019,wcfs international curriculum,mvc2,javascript tutorial w3school,ado.net entity data model visual studio 2017,javascript tutorial github,chase online,wcf api,costco,server jobs near me,webex,sql meaning,sql tutorial,sql commands,javascript tutorial video,ado.net entity framework,ajax tavern,tutorialsteacher,ajax javascript,javascript tutorial for frontend developers,services desk,ajax greek,csharp tutorial,mvc pattern,ado.net sql server,ado.net connection,asp.net identity,mvcu,asp.net core middleware,wcf web service,mvc webadvisor,web store,mvcc,webmail,mvci,mvctc,
Không có nhận xét nào:
Đăng nhận xét