`
reverocean
  • 浏览: 195510 次
  • 性别: Icon_minigender_1
社区版块
存档分类
最新评论

OOP in JS

阅读更多
JavaScript is different from others object-oriented language like c++,java.It's not based on the concept of class,but it uses to a concept named prototype.

The public,private and static of oop concepts can be  implemented by prototype in javascript.The following are the methods to implement these concepts:

private variables are declared with 'var' key word inside the object,and can only be accessed by private functions and privileged methods.

private functions are declared inline inside object's constructor(or alternatively may be defined via var functionName=function(){...}) and may be called by privileged methods(include the object's constructor).

privileged methods are declared with this.methodName=function(){...} and may invoked by code external to the object.

public properties are declared with this.variableName and may be read/writen from outside the object.

public methods are defined by Classname.prototype.methodName = function(){...} and may be called from outside the object.

prototype properties are defined by Classname.prototype.propertyName= someValue

static properties are defined by Classname.propertyName = someValue




an usefull link
分享到:
评论

相关推荐

    Modular Programming with JavaScript(PACKT,2016)

    Find out how the module design pattern is used in OOP in JavaScript Design and augment modules using both tight augmentation and loose augmentation Extend the capabilities of modules by creating sub-...

    prototype_oop_javascript_ruby_prototype_

    同时,Ruby支持模块(Module),可以用来实现类似于JavaScript原型的混入(Mix-in)行为: ```ruby module Sayable def say_hello puts 'Hello, ' + self.name end end class Person attr_accessor :name end ...

    Object-Oriented Programming in Javascript

    本书《Object-Oriented Programming in Javascript》是为了解决如何在JavaScript中正确应用面向对象编程(OOP)问题而撰写的,作者是曾任职于雅虎的前端工程师范 Nicholas C. Zakas。全书将涵盖JavaScript中面向对象...

    mkbug.js:一个基于expressjs的OOP风格的Node.js Web框架

    一个基于OOP风格的基于Express.js的Nodejs框架声明! 什么是mkbug.js 一个基于Express.js的OOP风格的Restful Api框架,使Node.js的开发既轻松又漂亮。 Mkbug.js VS Egg.js VS Think.js 项目 Mkbug.js Egg.js ...

    .Principles.of.Object-Oriented.Programming.in.JavaScript

    ### 面向对象编程(OOP)在JavaScript中的原则 #### 学习目标与概述 本书《面向对象编程在JavaScript中的原则》旨在帮助读者深入理解并掌握如何在JavaScript环境中运用面向对象编程(OOP)的概念和技术。对于那些...

    js-oop:JavaScript 面向对象编程

    JavaScript,作为一种广泛应用于Web开发的动态脚本语言,其面向对象编程(Object-Oriented Programming...在"js-oop"的压缩包中,可能包含了一些示例代码或教程,可以帮助你进一步学习和实践JavaScript的面向对象编程。

    Battle City Game in JavaScript with Source Code.zip

    "Battle City Game in JavaScript with Source Code.zip"是一个利用JavaScript编写的“坦克大战”游戏项目,其中包含了完整的源代码,为开发者提供了一个学习和实践JavaScript游戏开发的宝贵资源。 首先,我们要...

    Whack a Mouse Game in JavaScript Free Source Code.zip

    6. **面向对象编程**:在高级的JavaScript开发中,面向对象编程(OOP)是常见的设计模式。在这个游戏里,可能有Mouse类表示地鼠,Game类管理整个游戏流程,这些类封装了各自的功能,提高了代码的可维护性和复用性。 ...

    Simple Tower Block Game in JavaScript Free Source Code.zip

    总的来说,"Simple Tower Block Game in JavaScript"利用了JavaScript的灵活性和交互性,展示了如何在浏览器环境中构建一款简单的游戏。通过学习和分析这款游戏的源代码,开发者不仅可以掌握JavaScript的基本语法,...

    Javascript.Object.Oriented.Programming.pdf

    Learn to build scalable server application in JavaScript using Node.js Generate instances in three programming languages: Python, JavaScript, and C# Work with a combination of access modifiers, ...

    OOP-2:OOP练习

    将函数命名为askUser() 这些是用户可以选择的命令• log in• sign up• exit• search• log out• follow除了可以对每个选项执行if语句外,您还可以进行切换,并且组织得更好。 阅读: : ) 如果用户选择程序...

    OOChess:使用面向对象的Javascript和Jquery制作的国际象棋游戏

    **面向对象JavaScript(OOP in JavaScript):** 面向对象编程是一种软件设计模式,它将数据和操作数据的方法封装在对象中。JavaScript虽然是一种基于原型的语言,但同样支持类的概念,可以创建构造函数和实例,...

    JavaScript Object Programming(Apress,2015)

    JavaScript’s object programming (not inheritance) is what separates it from classical OOP languages like C++ and Java. Most important, basing inheritance on JavaScript’s prototypal chain is possible...

    HTML+Java+JavaOOP+JQuery+JSP+Hibernate+Spring+Struts+人事面试

    Java是一种广泛使用的面向对象编程语言(JavaOOP),其特性包括封装、继承、多态和抽象。JavaOOP允许开发者创建可复用的代码模块,提高效率。面试时,面试官可能会询问关于类、对象、接口、异常处理和集合框架等方面...

Global site tag (gtag.js) - Google Analytics