user962206
user962206

Reputation: 16117

javascript APIs?

I am currently studying Javascript and I was wondering if there are any APIS in it? in java we have java.awt.JFrame etc, in C# we have System.Console and etc. in javascript are there any apis? or what do you call those libraries in javascript?

Upvotes: 1

Views: 146

Answers (4)

Tim M.
Tim M.

Reputation: 54368

System and java.awt are namespaces. You can create namespaces (of a sort) in JavaScript; by default, every type belongs to the global namespace.

There are a handful of intrinsic objects in the global namespace such as Date and Array. These objects are instantiable and expose various methods. Math behaves more like a singleton/static type. Document and Window are available within a web browser and are not directly instantiable, though there can be multiple instances in use at a single time (parent and child window, for example). Collectively, these form a limited API.

Global objects from Mozilla

More on intrinsic objects from Microsoft (there are proprietary items in the list).

Many developers build elaborate namespace and class structures to form APIs in JavaScript. Check out Google Charts for a great example (note word "API" right in the URL).

Here is the instantiation of a namespaced type:

var chart = new google.visualization.PieChart(foo);
chart.draw(data, options);

Here is the loading of a "package":

google.load('visualization', '1.0', {'packages':['corechart']});

Upvotes: 3

Jon Nylander
Jon Nylander

Reputation: 8963

This is a good resource for learning the basic API: https://developer.mozilla.org/en/JavaScript/Reference

Other than the core components of the language, the APIs (or libraries) available depend on what APIs (or libraries) that you yourself decide to include, and on which environment you are running JavaScript.

If you run JavaScript in the browser you automatically have access to Document Object Model APIs for example. If you run in another virtual machine such as Node.js - you will have access to networking APIs.

But mostly, you will yourself find libraries that you want to use, and include them yourself.

Upvotes: 2

Lasantha Bandara
Lasantha Bandara

Reputation: 809

Javascript is a scripting language that runs on web browsers. So you can call the browser API with Javascripts. As an example you can see the google chrome API here, that can be invoked by Javascripts.

As well as some web applications provide an API for Javascripts like this(Google Maps API).

If you want a library of Javascripts check Jquery and Jqueryui

Upvotes: 0

hippietrail
hippietrail

Reputation: 16974

Yes. And no.

JavaScript as it runs in the browser has certain global functions and gobal objects which have methods.

The most obvious of these is the DOM (Document Object Model) which represents the web page loaded in the browser.

But there are also string functions, etc.

Now if JavaScript is not hosted in a browser, such as node.js for instance, you will not have the DOM, but I'm not sure which if any of the global functions are defined to be part of JavaScript and which are part of the browser implementations.

Here's something to get you started on the global functions from w3schools.com.

Upvotes: 0

Related Questions