Skip to main content

what is javascript ?

JavaScript, often abbreviated as JS, is a programming language that is one of the core technologies of the World Wide Web, alongside HTML and CSS. As of 2022, 98% of websites use JavaScript on the client side for webpage behavior, often incorporating third-party libraries. Wikipedia जावास्क्रिप्ट एक कम्प्यूटर प्रोग्रामिंग भाषा है। यह एक स्क्रिप्टिंग भाषा है और मुख्यतः क्लाएंट साइड में वेबपेज के निर्माण में प्रयुक्त होती है। विकिपीडिया जावास्क्रिप्ट Designed by: Brendan Eich Typing discipline: Dynamic, weak, duck Stable release: ECMAScript 2021 / June 2021; 18 months ago First appeared: December 4, 1995; 27 years ago Paradigm: Multi-paradigm: event-driven, functional, imperative, procedural, object-oriented programming Not to be confused with Java (programming language), Javanese script, or ECMAScript. ".js" redirects here. For the Microsoft dialect used in Internet Explorer, see JScript. For the uses of JavaScript on Wikipedia, see Wikipedia:WikiProject JavaScript. JavaScript (/ˈdʒɑːvəskrɪpt/), often abbreviated as JS, is a programming language that is one of the core technologies of the World Wide Web, alongside HTML and CSS. As of 2022, 98% of websites use JavaScript on the client side for webpage behavior, often incorporating third-party libraries. All major web browsers have a dedicated JavaScript engine to execute the code on users' devices. JavaScript JavaScript screenshot.png Screenshot of JavaScript source code with HTML

Welcome to the jaat computers beginner's JavaScript course! In this article we will look at JavaScript from a high level, answering questions such as "What is it?" and "What can you do with it?", and making sure you are comfortable with JavaScript's purpose.


Prerequisites: Basic computer literacy, a basic understanding of HTML and CSS.
Objective: To gain familiarity with what JavaScript is, what it can do, and how it fits into a web site.



A high-level definition




JavaScript is a scripting or programming language that allows you to implement complex features on web pages — every time a web page does more than just sit there and display static information for you to look at — displaying timely content updates, interactive maps, animated 2D/3D graphics, scrolling video jukeboxes, etc. — you can bet that JavaScript is probably involved. It is the third layer of the layer cake of standard web technologies, two of which (HTML and CSS) we have covered in much more detail in other parts of the Learning Area.

  • HTML is the markup language that we use to structure and give meaning to our web content, for example defining paragraphs, headings, and data tables, or embedding images and videos in the page.
  • CSS is a language of style rules that we use to apply styling to our HTML content, for example setting background colors and fonts, and laying out our content in multiple columns.
  • JavaScript is a scripting language that enables you to create dynamically updating content, control multimedia, animate images, and pretty much everything else. (Okay, not everything, but it is amazing what you can achieve with a few lines of JavaScript code.)

The three layers build on top of one another nicely. Let's take a simple text label as an example. We can mark it up using HTML to give it structure and purpose:


Then we can add some CSS into the mix to get it looking nice:



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


And finally, we can add some JavaScript to implement dynamic behavior:



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





Try clicking on this last version of the text label to see what happens (note also that you can find this demo on GitHub — see the source code, or run it live)!

JavaScript can do a lot more than that — let's explore what in more detail.

So what can it really do?



The core client-side JavaScript language consists of some common programming features that allow you to do things like:
  • Store useful values inside variables. In the above example for instance, we ask for a new name to be entered then store that name in a variable called name.
  • Operations on pieces of text (known as "strings" in programming). In the above example we take the string "Player 1: " and join it to the name variable to create the complete text label, e.g. "Player 1: Chris".
  • Running code in response to certain events occurring on a web page. We used a click event in our example above to detect when the label is clicked and then run the code that updates the text label.
  • And much more!
What is even more exciting however is the functionality built on top of the client-side JavaScript language. So-called Application Programming Interfaces (APIs) provide you with extra superpowers to use in your JavaScript code.

APIs are ready-made sets of code building blocks that allow a developer to implement programs that would otherwise be hard or impossible to implement. They do the same thing for programming that ready-made furniture kits do for home building — it is much easier to take ready-cut panels and screw them together to make a bookshelf than it is to work out the design yourself, go and find the correct wood, cut all the panels to the right size and shape, find the correct-sized screws, and then put them together to make a bookshelf.
They generally fall into two categories.


Browser APIs are built into your web browser, and are able to expose data from the surrounding computer environment, or do useful complex things. For example:
  • The DOM (Document Object Model) API allows you to manipulate HTML and CSS, creating, removing and changing HTML, dynamically applying new styles to your page, etc. Every time you see a popup window appear on a page, or some new content displayed (as we saw above in our simple demo) for example, that's the DOM in action.
  • The Geolocation API retrieves geographical information. This is how Google Maps is able to find your location and plot it on a map.
  • The Canvas and WebGL APIs allow you to create animated 2D and 3D graphics. People are doing some amazing things using these web technologies — see Chrome Experiments and webglsamples.
  • Audio and Video APIs like HTMLMediaElement and WebRTC allow you to do really interesting things with multimedia, such as play audio and video right in a web page, or grab video from your web camera and display it on someone else's computer (try our simple Snapshot demo to get the idea).


  • What is JavaScript doing on your page?


    Here we'll actually start looking at some code, and while doing so, explore what actually happens when you run some JavaScript in your page.

    Let's briefly recap the story of what happens when you load a web page in a browser (first talked about in our How CSS works article). When you load a web page in your browser, you are running your code (the HTML, CSS, and JavaScript) inside an execution environment (the browser tab). This is like a factory that takes in raw materials (the code) and outputs a product (the web page).


    A very common use of JavaScript is to dynamically modify HTML and CSS to update a user interface, via the Document Object Model API (as mentioned above). Note that the code in your web documents is generally loaded and executed in the order it appears on the page. Errors may occur if JavaScript is loaded and run before the HTML and CSS that it is intended to modify. You will learn ways around this later in the article, in the Script loading strategies section.

    Browser security



    Each browser tab has its own separate bucket for running code in (these buckets are called "execution environments" in technical terms) — this means that in most cases the code in each tab is run completely separately, and the code in one tab cannot directly affect the code in another tab — or on another website. This is a good security measure — if this were not the case, then pirates could start writing code to steal information from other websites, and other such bad things.

    JavaScript running order



    When the browser encounters a block of JavaScript, it generally runs it in order, from top to bottom. This means that you need to be careful what order you put things in. For example, let's return to the block of JavaScript we saw in our first example:

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

    Here we are selecting a text paragraph (line 1), then attaching an event listener to it (line 3) so that when the paragraph is clicked, the updateName() code block (lines 5–8) is run. The updateName() code block (these types of reusable code blocks are called "functions") asks the user for a new name, and then inserts that name into the paragraph to update the display.

    If you swapped the order of the first two lines of code, it would no longer work — instead, you'd get an error returned in the browser developer console — TypeError: para is undefined. This means that the para object does not exist yet, so we can't add an event listener to it.

Comments

Popular posts from this blog

attitude shayari in hindi

तुम्हाला काही सेकंदांमध्ये रीडिरेक्ट न केल्या गेल्यास कृपया येथे क्लिक करा. attitude shayari in hindi - Google Search अ‍ॅक्सेसिबिलिटी लिंक मुख्य आशयावर जा ॲक्सेसिबिलिटी मदत × क्विक सेटिंग्ज शोध मोड सर्व इमेज व्हिडिओ पुस्तके बातम्या आणखी Maps Flights Finance क्विक सेटिंग्ज सर्व Search सेटिंग्ज पहा तुमची अ‍ॅक्टिव्हिटी शोध कस्टमायझेशन सेव्ह करत आहे Search मधील तुमच्या डेटाबद्दल अधिक जाणून घ्या Search वापरून सुरक्षितशोध सुरक्षितशोध चे सेटिंग व्यवस्थापित करा भाषा मराठी प्रगत शोध स्वरूप फिकट थीम गडद थीम डिव्हाइसचे डीफॉल्ट सेटिंग सपोर्ट शोध मदत टूल संग्रह सुरक्षितशोध लैंगिकरीत्या भडक असलेले परिणाम लपवा सुरक्षितशोध बद्दल अधिक आकार रंग टाइप करा वेळ वापराचे हक्क सुधारणा 2 line status instagram girl attitude line attitude instagram attitude boy attitude sad shayari two line shayari attitude quotes लाइन शायरी शोध परिणाम इमेज परिणाम 100+ Attitude Shayari in Hindi | ऐटिटूड शायरी हिंदी में - Achi Shayari Shayari | Quotes 100+ Attitude Shayari in Hindi | ऐटिटूड शायरी हिंदी में - Achi Shayari Be...

Computer technology definition

Computer Technology means any and all electronic media and services, including computers, software, e-mail, telephones, voicemail, facsimile machines, online services, internet, provided to employees by the City. Short-Cut Key Kya Hoti Hai और Computer की शॉर्टकट की का उपयोग कैसे किया जाता है एवं कंप्यूटर की महत्वपूर्ण शॉर्टकट कीस कौन कौन सी है दोस्तों जैसे कि हम सब जानते हैं कि इंडिया एक डिजिटल इंडिया होता जा रहा है और आजकल हर चीज ही हम ऑनलाइन करते हैं। ऐसे में कंप्यूटर का उपयोग बढ़ता जा रहा है। और अगर हमें कंप्यूटर में काम जल्दी करना है तो उसके लिए हमें कंप्यूटर की शॉर्टकट की के बारे में संपूर्ण जानकारी होनी चाहिए। कंप्यूटर में शॉर्टकट कीस के माध्यम से हम काले काफी जल्दी कर सकते हैं।अगर आपको कंप्यूटर की शॉर्टकट कीस के बारे में संपूर्ण जानकारी नहीं है तो आप बिल्कुल सही पोस्ट पढ़ रहे हैं आज हम आपको अपने आर्टिकल के माध्यम से Computer की Short-Cut Key के बारे में संपूर्ण जानकारी प्रदान करने जा रहे हैं आपको हमारा आर्टिकल ध्यान पूर्वक पढ़ना होगा। Click Here sort keys sort keys sort k...

Computer technology

Computer Technology means all scientific and technical information or material pertaining to any machine, appliance or process, including specifications, proposals, models, designs, formulas, test results and reports, analyses, simulation results, tables of operating conditions, materials, components, industrial skills, operating and testing procedures, shop practices, know-how and show-how; Information technology (IT) is the use of computers to create, process, store, retrieve, and exchange all kinds of data[1] and information. IT forms part of information and communications technology (ICT).[2] An information technology system (IT system) is generally an information system, a communications system, or, more specifically speaking, a computer system — including all hardware, software, and peripheral equipment — operated by a limited group of IT users. A program in paper tape Although humans have been storing, retrieving, manipulating, and communicating information since the earlies...