JavaScript Basics

JavaScript Basics

Prototype-based Programming

  • A style of object-oriented programming where classes are not present
  • Inheritance is performed by cloning existing objects that serve as prototypes
    • There are no explicit classes and objects inherit directly from other objects
    • Objects are linked through the prototype property
  • Delegation is the language feature that supports prototype-based programming
  • Also known as classless, prototype-oriented or instance-based programming

JavaScript

  • A prototype-based lightweight programming language commonly used in web browsers
  • The most widely used scripting language on the Internet
  • It works in all major browsers
  • Was designed to add interactivity to HTML pages
  • Can be embedded directly into HTML pages or placed in external .js files
  • Is an interpreted language, which means that scripts execute without preliminary compilation
  • Everyone can use JavaScript without purchasing a license

JavaScript Uses

  • Can be set to execute when something happens, like when a page has finished loading or when a user clicks on an HTML element
  • Can read and write HTML elements
  • Can be used to validate data before it is submitted to a server
  • Can be used to detect the visitor's browser and load another page specifically designed for that browser
  • Can be used to create and retrieve information from cookies
  • HTML designers and others can add small "snippets" of JavaScript to their HTML pages

Sources