What is javascript?

  What is JavaScript?



JavaScript is a scripting language used to create and control dynamic website content—but that might make a lot of sense if you’re new to tech. So let’s replace “dynamic website content” with “things that move, refresh, or otherwise change on your screen without requiring you to manually reload a web page.”
Think features like animated graphics, photo slideshows, autocomplete text suggestions, and interactive forms. Or even better, think about web features you completely take for granted, like when your Facebook timeline updates on your screen or Google suggests search terms based on a few letters you’ve typed into your search bar. In both cases, that’s JavaScript in action.
If you’re reading this, though, then you know that there’s a lot that goes into JavaScript and how web developers use it. Here at Skillcrush, we teach an entire segment on JavaScript in our Front End Web Developer and Break into Tech Blueprints. So yeah, there’s a lot more to get into in this article.

What are the Basics of JavaScript?

If you’re hoping to break into a career in tech, your question might sound more like: “what is JavaScript and do I need it?”
You can see from the examples above that—if you’re interested in web development—the answer is a resounding yes. So with that out of the way, let’s go a bit deeper into how JavaScript works and what you’ll really use it for.
I mentioned above that JavaScript is a “scripting language.” Scripting languages are coding languages used to automate processes that users would otherwise need to execute on their own, step-by-step. Short of scripting, any changes on web pages you visit would require either manually reloading the page, or navigating a series of static menus to get to the content you’re after
A scripting language like JavaScript (JS, for those in the know) does the heavy lifting by telling computer programs like websites or web applications to “do something.” In the case of JavaScript, this means telling those dynamic features described earlier to do whatever it is they do—like telling images to animate themselves, photos to cycle through a slideshow, or autocomplete suggestions to respond to prompts. It’s the “script” in JavaScript that makes these things happen seemingly on their own.
JavaScript comes built into your web browser
Because JavaScript is such an integral part of web functionality, all major web browsers come with built-in engines that can render JavaScript. This means JS commands can be typed directly into an HTML document, and web browsers will be able to understand them. In other words, using JavaScript doesn’t require downloading any additional programs or compilers.

Vanilla JavaScript

To give you an idea of what JavaScript looks like, consider the following basic example of JavaScript code. If you wanted users to receive a “thanks for signing up” confirmation message after signing up for an offer or service on a website, you would code it directly into an HTML page (between <script> tags) like this:
<script>
window.onload = initAll;
function initAll() {
document.getElementById(“submit”).onclick = submitMessage;
}
function submitMessage() {
var greeting = document.getElementById(“name”).getAttribute(“value”);
document.getElementById(“headline”).innerHTML = “Thank you for joining our email list,” + greeting;
return false;
}
<script/>
Writing out this kind of code and inserting JavaScript in HTML docs is called “Vanilla JavaScript.” Vanilla JS alone can be used to create JavaScript projects, but as you become more familiar with the JavaScript language, there are different tools you can implement to make JS easier and more efficient to use.

JavaScript Tools

jQuery

When you work with JavaScript, you’ll notice JS functions and features that show up regularly across multiple websites or web apps—things like menu animations and fade outs, file upload forms, and image galleries. While you could code each of these things from the ground up every time you need one, your coding life will feel a lot easier if you use coding libraries like jQuery instead.
The jQuery library is made up of JavaScript coding functions that can be performed through single line jQuery commands. For example, the JavaScript code example above looks like this if it’s performed using jQuery code instead:
<script>
$(“#submit”).click(function () {
var greeting = $(“#name”).val();
$(“#headline”).html(“Thank you for joining our email list, ” + greeting);
return false;
});
<script/>
As you can see, the jQuery programming approach is a lot more concise, and it can be reused any time you want to perform the same JavaScript function while coding a website or web app.
In addition to examples like the one above (which are considered jQuery snippets—snippets of code inserted directly from the jQuery library to perform dedicated functions), jQuery code can be put together to create more complicated plugins. jQuery plugins can be found directly from the jQuery UI (User Interface) repository, where source code is available for copying and pasting.

JavaScript Frameworks

While JS libraries like jQuery function as digital Swiss Army knives for individual coding needs, front-end developers can take things a step farther by using tools called JavaScript frameworks.
Extending past the patchwork functionality of jQuery, JS frameworks provide JavaScript developers with templates for websites or web applications to be built around. JS frameworks create spaces in a template where JS code is recommended to go, as well as prewritten code (much like jQuery) that can be plugged into those spaces.

Post a Comment

0Comments

Please Select Embedded Mode To show the Comment System.*