摘要
随着JavaScript语言的应用越来越广泛,它的代码也变得越来越复杂,面向对象编程就成了必然的选择。然而JavaScript语言中没有"类"(class)的概念,这就给程序设计造成了不便。对用JavaScript语句模拟"类"的方法进行了研究,主要针对使用构造函数的方法和使用对象字面量(object literal)的方法,对二者的语法结构和实现效果进行了分析和比较,找到了最佳的方案。
With the JavaScript language is applied more and more widely, its code has become more and more complex,the object oriented programming became inevitable option.However,JavaScript does not have a concept of "class",which bring inconvenience to the program design.This paper has studied the methods of Using JavaScript code to simulate the "class",mainly for the methods of using constructor and using object literal,analyzed and compared the grammatical structure and the final results.Finally,the best solution has been found.
出处
《电脑开发与应用》
2012年第12期58-60,共3页
Computer Development & Applications