Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What type of language is JavaScript

Tags:

javascript

oop

I'm in a beginning HTML class and our textbook says that JavaScript is an object-based scripting language. On our quiz, one of the questions was "JavaScript is an object-oriented scripting language, True or False." I put False because it's my understanding that object-based and object-oriented are two different things. I got the answer wrong.

Is JavaScript indeed an object-oriented language?

Thanks for any clarification you can give!

like image 971
pumkin54 Avatar asked Dec 09 '25 22:12

pumkin54


2 Answers

JavaScript uses prototype-based programming, which is a type of object oriented programming. Prototypes are a way of reusing behaviors by cloning existing objects instead of doing class based inheritance. It's different enough from the standard class based object oriented programming that few people bother to learn it well enough to make good use of it.

http://en.wikipedia.org/wiki/Prototype-based_programming is a useful reference.

like image 161
Bharat Mediratta Avatar answered Dec 12 '25 12:12

Bharat Mediratta


The definition of Object Oriented is sometimes subjective. For some, any language that deals with "Objects", is Object Oriented. For others, the entire language and its construct must utilize objects to be counted as Object Oriented (think SmallTalk or Java).

In javascript, you're able to write a script that has no objects in it or you can create heavily object oriented code. Whether or not you call it Object Oriented is really dependant on what school of thought you follow.

like image 38
ajacian81 Avatar answered Dec 12 '25 12:12

ajacian81