Technical Articles

Tech Articles from your friends at Oracle and the developer community.


                                  What Is JavaScript?

                                  Anyone familiar with computer programming is most likely aware of JavaScript. But awareness isn't enough. You must understand how to take advantage of its capabilities.

                                  Have you ever wanted to animate snow falling over your front page during the winter holidays?

                                  JavaScript can turn your website into an interactive experience for your audience. They can marvel at the customization made for them. Read on to learn about JavaScript features that will empower your site.

                                  JavaScript Defined

                                  JavaScript is a programming language used to create and control dynamic website content. (i.e. anything that moves, refreshes, or changes on-screen without reloading a web page).

                                  JavaScript features:

                                  • Slideshows
                                  • Animations
                                  • Autocomplete text suggestions
                                  • Interactive forms

                                  JavaScript allows your webpage to update your Facebook and Twitter feed in real-time.

                                  HTML, CSS, and JavaScript for Web Developers

                                  HTML, CSS, and JavaScript are the backbone of web development. HTML creates the structure of a web page. CSS controls how that page looks, and JavaScript makes the page dynamic or interactive.

                                  JavaScript can control website automation. The script tells the website what to do. This can include telling images to animate themselves or photos to cycle like a slide show. JavaScript can also suggest a form to autocomplete its blanks based on prompts.

                                  All major browsers come with the ability to render JavaScript. This means JS commands get placed in an HTML document that the browser can read. It can be instantly used without any extra software.

                                  JavaScript is also in apps for mobile devices. Another use is to create interactivity for browser-based games.

                                  Adding JavaScript to Website

                                  JavaScript can be embedded into a web page or included in a .js file. JavaScript is a client-side language, not a server-side program. It's downloaded to the user's computer and then processed.

                                  To add the code to your web page, you use the "script"tag and give it the type attribute "text/javascript".

                                  Here is a sample:

                                  <script type="text/javascript">JavaScript goes here. </sript>

                                  This program is then downloaded into the site-visitor's computer and run. The only caveat is if they have turned off their browser's ability to run JavaScript.

                                  Simple Javascript Example

                                  Here is an actual example:

                                           <title> JavaScript Example </title>
                                            <script type="text/javascript" src="jquery-1.7.1.min.js"></script>
                                            var myArray = ["Joe", "Sally", "Mary"]; 
                                             $.each(myArray, function (index, element) { 

                                  What are JavaScript Objects

                                  An object is a set of properties and methods. A property can be anything from a string or a number, to an image or another object. Properties are accessed with the dot operator notation (eg., ) and methods are called with a function call syntax (myObjectObject.<methodToCall>() ).

                                  Javascript objects are unique in that they are values. This is unlike other languages where objects are a reference type.

                                  Object properties and methods use dot notation or brackets. An object passes by reference from one function to another. It can also include another object as a property.

                                  A JavaScript object is a standalone entity. It holds many property and method values. The object property stores a literal value and the method represent a function. Creating an object can be done using object literal or object constructor syntax.

                                  Example of Object Literal

                                  var person = {
                                       firstName: "Santa",
                                       lastName: "Clause",
                                       age: 2022,
                                       getFullName: function () {
                                       return this.firstName + ' ' + this.lastName

                                  Example of Object Constructor

                                  var person = new Object();
                                       person.firstName = "Santa";
                                       person.lastName = "Clause";
                                       person.age: 2022;
                                       person.getFullName = function () {
                                       return this.firstName + ' ' + this.lastName;

                                  JavaScript Array

                                  Javascript arrays and objects are similar, but not the same. Objects are a specialized array. Arrays, no matter what data you put into them, will always have a "0" index, and objects will not.

                                  An array is an ordered sequence of values. They can hold many related items. This makes them ideal for storing lists of form inputs such as online shopping cart products.

                                  Objects designed to hold strings or numbers as properties will do so no matter what your index is on them.

                                  An example of this would be:

                                  var myObject = {a:1,b:"This is a string",c:[1,"Another String"]},
                                       myArray = ["something", 1.2, "and an array"];
                                       //outputs ["something", 1.2, "and an array"].
                                  If I put in "myObject" as the array, it will output ["something", 1.2]

                                  Why do Arrays Work as Objects in JavaScript?

                                  The obvious question to consider is why arrays work as objects in JavaScript. This odd behavior is the result of how browsers handle objects, and it's a good thing.

                                  Once a browser handles an object like an array, for example, that object belongs to the browser. That means you can access the object from another file in your program when using the same browser. You'll have access to whatever methods and properties belong to that object.

                                  Let's look at it from another perspective.

                                  Arrays work as Javascript objects because arrays are JavaScript objects. Other files can access any array using the same browser. In essence, when you create a new array, you're creating an object defined by type 'Array'.

                                  This means that the array you created is not one big list of numbers or strings. Instead, it's an object with its own methods and properties.

                                  If you access your newly-created array as a normal object, it will have its own methods and properties. These properties are the same ones you defined when you created the array. Methods on this new object can get or set values in the array.

                                  Developers don't need to worry about creating objects that belong to a browser. JavaScript informs the browser how to handle objects. This process adds instructions between your code and the underlying object technology.

                                  At first glance, arrays as JavaScript objects might seem odd. It shines when developers use other files to manipulate array properties and methods.

                                  Why is JavaScript Called a Scripting Language?

                                  A programming language is a formal language with rules. The language specifies a set of instructions that can produce various outputs. These outputs include things like the display of text on monitors, printers, or web pages.

                                  Programming languages can also control machine actions. This includes music playback, cameras, and any other action performed by computers. The system interprets the script to perform an action. Scripting languages are dynamically typed with little or no compile time.

                                  JavaScript History

                                  Rumors suggested JavaScript got its name because it resembles Java. But it was actually developed by Brendan Eich before there was a Java language. Mocha was the first form of JavaScript that debuted in May 1995.

                                  The name changed to LiveScript early in 1996. Then it changed to JavaScript with the release of Netscape Navigator 2.0 in December of that same year.

                                  A common myth says the term "Java" came from the word "Java" in the coffee industry and that Java is a type of coffee. But Java was actually named after the Indonesian island of Java where its creator lived.

                                  It's believed that Netscape used JavaScript as an internal programming language. The idea was to use it for their web browser so they could enhance it without having to learn C++.

                                  When the language went public in 1995, it did not get much attention. But attention exploded once Internet Explorer began supporting it in version 3.

                                  What Is JavaScript Used For?

                                  JavaScript has a great user experience. Its dynamic features allow users to change text and content. This includes the ability to resize images to fit within a website.

                                  With a simple click of a button, the user can display certain information. They can click on a menu label that reveals a pulldown menu for their selection.

                                  Users can even zoom in and out of images for a better view.

                                  To simplify complex info, JavaScript can create tabs on a website for easy perusal of content. There is also a great benefit for users in the added ability to play animations, audio, and video.

                                  Backend Development

                                  JavaScript works in combination with Node.js behind the scenes to save form data on the server. For instance, by using JavaScript as a server-side language, you can process payments, save comments, and handle other backend routines.

                                  For JavaScript developers who are interested in Node.js and other JavaScript use cases, Oracle offers many resources. Check out Oracle’s JavaScript resources here.

                                  Mobile App Development

                                  In the past, initial apps required operating system programming. JavaScript is now used to develop apps. Other companies have joined in like Adobe's Phonegap.

                                  But JavaScript SDK or library of content makes it the easiest mobile app builder.

                                  Game Development

                                  JavaScript is often used in simple online games like Cookie Clicker. Any game with a simple structure can take advantage of JavaScript. Games that need complexity or large gaming worlds are often built using other tools.

                                  JavaScript Make Web Pages Dynamic

                                  The programming language of JavaScript makes web pages interactive. It can feature slides, animations, music, and videos. And, it can draw information from social media in real-time.

                                  Now you understand this quick overview of JavaScript and its capabilities. To learn more, consider reading another article on a similar topic.

                                  Latest content

                                  Explore and discover our latest tutorials

                                  Serverless functions

                                  Serverless functions are part of an evolution in cloud computing that has helped free organizations from many of the constraints of managing infrastructure and resources. 

                                  What is a blockchain?

                                  In broad terms, a blockchain is an immutable transaction ledger, maintained within a distributed peer-to-peer (p2p) network of nodes. In essence, blockchains serve as a decentralized way to store information.

                                  OCI CLI

                                  The CLI is a small-footprint tool that you can use on its own or with the Console to complete Oracle Cloud Infrastructure tasks. The CLI provides the same core functionality as the Console, plus additional commands.