Welcome come the MDN beginner"s JavaScript course! In thisarticle we will certainly look at JavaScript from a high level, answering concerns such as "What is it?" and also "What can you carry out with it?", and making certain you room comfortable v JavaScript"s purpose.

You are watching: What does js mean in text

Prerequisites: Objective:
Basic computer system literacy, a basic understanding the HTML and also CSS.
To obtain familiarity v what JavaScript is, what it can do, and also how it fits into a net site.

JavaScript is a scripting or programming language that permits you come implement facility features on net pages — every time a internet page does an ext than simply sit there and also display static details for you come look in ~ — displaying timely contents updates, interactive maps, animated 2D/3D graphics, scrolling video jukeboxes, etc. — you deserve to bet that JavaScript is probably involved. That is the 3rd layer that the class cake of standard net technologies, 2 of which (HTML and CSS) we have actually covered in much more detail in various other parts that the learning Area.


The 3 layers construct on top of one one more nicely. Let"s take a straightforward text label as an example. We have the right to mark it up utilizing HTML to offer it structure and purpose:

p>Player 1: Chrisp>


Then us can include some CSS into the mix to get it feather nice:

p font-family: "helvetica neue", helvetica, sans-serif; letter-spacing: 1px; text-transform: uppercase; text-align: center; border: 2px hard rgba(0,0,200,0.6); background: rgba(0,0,200,0.3); color: rgba(0,0,200,0.6); box-shadow: 1px 1px 2px rgba(0,0,200,0.4); border-radius: 10px; padding: 3px 10px; display: inline-block; cursor: pointer;


And finally, us can include some JavaScript to implement dynamic behavior:

const para = document.querySelector("p");para.addEventListener("click", updateName);function updateName() let name = prompt("Enter a new name"); para.textContent = "Player 1: " + name;

Try clicking on this last version of the text label to view what wake up (note additionally that girlfriend can uncover this demo on GitHub — watch the resource code, or operation it live)!

JavaScript have the right to do a lot more than that — let"s check out what in an ext detail.

So what have the right to it really do?

The core client-sideJavaScript language consists of some usual programming attributes that allow you to perform things like:

Store useful values within variables. In the above example for instance, we ask for a brand-new name to be entered then store that surname in a variable referred to as name. To work on pieces of text (known as "strings" in programming). In the over example us take the string "Player 1: " and join it to the surname variable to develop the finish text label, e.g. ""Player 1: Chris". and much more!

What is even much more exciting however is the functionality built on top of the client-side JavaScript language. So-called Application Programming Interfaces (APIs) provide you v extra superpowers to use in her JavaScript code.

APIs room ready-made to adjust of code structure blocks that enable a hunterriverpei.com to implement programs that would certainly otherwise be difficult or impossible to implement. They execute the exact same thing because that programming that ready-made furniture kits carry out for home building — it is much much easier to take it ready-cut panels and screw them with each other to do a bookshelf 보다 it is to work-related out the style yourself, go and also find the correct wood, cut all the panels to the appropriate size and also shape, find the correct-sized screws, and then put them with each other to make a bookshelf.

They generally loss into 2 categories.


Browser APIs are constructed into your net browser, and are maybe to expose data indigenous the surrounding computer environment, or carry out useful complex things. Because that example:

Note: numerous of the over demos won"t job-related in one older browser — once experimenting, it"s a good idea to use a modern-day browser like Firefox, Chrome, leaf or Opera to operation your password in. Girlfriend will require to think about cross internet browser testing in more detail once you acquire closer come delivering production code (i.e. Actual code that real customers will use).

Third party APIs space not constructed into the internet browser by default, and you typically have to grab their code and also information from what on the Web. Because that example:

Note: these APIs space advanced, and we"ll no be covering any kind of of these in this module. You can find out much much more about these in our Client-side internet APIs module.

There"s a lot much more available, too! However, don"t get over excited just yet. You won"t have the ability to build the next Facebook, Google Maps, or Instagram after researching JavaScript because that 24 hrs — there are a most basics come cover first. And that"s why you"re below — let"s relocate on!

What is JavaScript doing on your page?

Here we"ll actually start looking at some code, and while law so, discover what in reality happens when you operation some JavaScript in her page.

Let"s briefly recap the story that what happens when you pack a internet page in a browser (first talked about in our how CSS functions article). When you load a net page in your browser, you are running your password (the HTML, CSS, and also JavaScript) within an execution atmosphere (the internet browser tab). This is prefer a factory that takes in raw products (the code) and also outputs a product (the web page).


A very common usage of JavaScript is to dynamically modify HTML and also CSS to upgrade a user interface, via the document Object version API (as stated above). Note that the code in her web records is normally loaded and executed in the stimulate it shows up on the page. Errors may take place if JavaScript is loaded and also run before the HTML and also CSS the it is intended to modify. You will find out ways around this later on in the article, in the manuscript loading techniques section.

Browser security

Each web browser tab has its own separate bucket because that running password in (these buckets are called "execution environments" in technological terms) — this means that in most cases the password in every tab is run completely separately, and the code in one tab can not directly affect the password in another tab — or on another website. This is a an excellent security measure — if this were no the case, climate pirates can start composing code to steal details from various other websites, and other such bad things.

Note: there are ways to send code and also data in between different websites/tabs in a for sure manner, but these are advanced techniques that we won"t sheathe in this course.

JavaScript running order

When the browser encounters a block of JavaScript, it typically runs it in order, from height to bottom. This means that you must be careful what bespeak you put things in. For example, let"s go back to the block the JavaScript we experienced in our an initial example:

const para = document.querySelector("p");para.addEventListener("click", updateName);function updateName() let surname = prompt("Enter a new name"); para.textContent = "Player 1: " + name;
Here us are picking a message paragraph (line 1), climate attaching an occasion listener to it (line 3) therefore that once the paragraph is clicked, the updateName() code block (lines 5–8) is run. The updateName() code block (these species of reusable password blocksare referred to as "functions") asks the user because that a brand-new name, and then inserts the name right into the paragraph to upgrade the display.

If you swapped the bespeak of the first two lines of code, it would certainly no longer work — instead, you"d acquire an error returned in the browser hunterriverpei.com console — TypeError: para is undefined. This means that the para thing does not exist yet, so we can"t include an event listener come it.

Note: This is a really common error — you should be careful that the objects referenced in your password exist prior to you shot to execute stuff come them.

Interpreted versus compiled code

You might hear the terms interpreted and also compiled in the paper definition of programming. In understood languages, the password is run from optimal to bottom and also the result of to run the code is automatically returned. Friend don"t need to transform the code into a different kind before the browser runs it. The password is obtained in that is programmer-friendly text type and processed directly from that.

Compiled languages on the other hand are transformed (compiled) into another kind before they space run by the computer. Because that example, C/C++ space compiled into maker code the is then operation by the computer. The regimen is executed from a binary format, i m sorry was produced from the original program source code.

JavaScriptis a lightweightinterpreted programming language. The web web browser receives the JavaScript code in its initial text kind and operation the manuscript from that. From a technical standpoint, most modern-day JavaScript interpreters actually use a technique called just-in-time compiling to improve performance; the JavaScript source code it s okay compiled into a faster, binaryformat while the script is gift used, so the it can be run as easily as possible. However, JavaScript is still taken into consideration an understood language, because the compilation is tackled at operation time, rather than ahead of time.

There are benefits to both types of language, but we won"t comment on them ideal now.

Server-side versus client-side code

You might also hear the terms server-side and also client-side code, specifically in the context of net development. Client-side password is password that is operation on the user"s computer — as soon as a internet page is viewed, the page"s client-side password is downloaded, then run and displayed by the browser. In thismodule us are clearly talking about client-side JavaScript.

Server-side code at the same time is operation on the server, climate its results are downloaded and displayed in the browser. Examples of well-known server-side internet languages encompass PHP, Python, Ruby,ASP.NET and... JavaScript! JavaScript can also be used as a server-side language, for instance in the well-known Node.js atmosphere — girlfriend can discover out an ext about server-side JavaScript in our Dynamic website – Server-side programming topic.

Dynamic versus revolution code

The word dynamic is provided to define both client-side JavaScript, and server-side language — it describes the capacity to update the display of a internet page/app to show different things in different circumstances, generating new content as required. Server-side password dynamically generates new content on the server, e.g. Pulling data indigenous a database, vice versa, client-side JavaScript dynamically generates brand-new content inside the browser on the client, e.g. Creating a new HTML table, filling it with data asked for from the server, then displaying the table in a internet page displayed to the user. The definition is slightly various in the 2 contexts, yet related, and both viewpoints (server-side and client-side) usually job-related together.

See more: How Old Do You Have To Be To Buy A Bong S In California If Under Age Of 21

A web page through no dynamically updating content is referred to as static — it simply shows the same content every the time.

How carry out you include JavaScript to her page?

JavaScript is applied to your HTML web page in a similar manner to CSS. Whereas CSS uses facets to apply external stylesheets and also facets to apply internal stylesheets come HTML, JavaScript only needs one girlfriend in the civilization of HTML — the