Posts

Showing posts with the label JavaScript

Understanding JavaScript Prototype

Function is its own constructor (i.e. "parent"). Function.constructor;  // function Function() { [native code] } Normally you can't do what you're doing. For example, this won't work: f = function () {}; f.prototype.a = 5; f.a;  // undefined This kind of thing only works if you use a function as a constructor, like so: f = function () {}; f.prototype.a = 5; g = new f(); g.a;  // 5 But Function is weird, it is the constructor for all functions and is also a function itself, so it templates its properties off its own prototype. Hence you can call Function.method() in your code. For more info about prototypal inheritance visit  http://javascript.info/tutorial/inheritance Source: Stackoverflow.

Introduction to Object Oriented JavaScript.

JavaScript is object-oriented to its core, with powerful, flexible  OOP  capabilities. This article starts with an introduction to object-oriented programming, then reviews the JavaScript object model, and finally demonstrates concepts of object-oriented programming in JavaScript. JavaScript review If you don't feel confident about JavaScript concepts such as variables, types, functions, and scope you can read about those topics in  A re-introduction to JavaScript . You can also consult the JavaScript Guide . Object-oriented programming Object-oriented programming is a programming paradigm that uses abstraction to create models based on the real world. It uses several techniques from previously established paradigms, including modularity, polymorphism, and encapsulation. Today, many popular programming languages (such as Java, JavaScript, C#, C++, Python, PHP, Ruby and Objective-C) support object-oriented programming (OOP). Object-oriented programming may be s...