Skip to content
  • About Us
  • Contact Us
  • Privacy Policy
  • Disclaimer
  • Corona Virus Stats (Covid-19)
  • Work with us
  • FB
  • LinkedIn
  • Twitter
  • Instagram.com
Tekraze

Tekraze

Dive Into Technology

  • Guides
    • Developer Guide
    • PC Guide
    • Web Guide
    • Android Guide
    • Music
    • Tutorials
  • Feed
    • Tech News
    • Shared Tech
    • Gaming Videos
    • Unboxing videos
  • Forums
    • Android Apps
    • Angular Npm Packages
    • Useful Site Links
    • Tech Queries
    • Windows OS Help
    • Web Guide and Help
    • Android Os And Rooting
    • Jhipster Discussion
    • Git & GitHub forum
    • Open Source Forum
  • Work with us
  • Toggle search form
javascript tekraze

JavaScript

Posted on May 23, 2018 By Anonymous 2 Comments on JavaScript

Table of Contents

  • An Introduction to JavaScript
    • What is JavaScript?
    • What can in-browser JavaScript do?
    • What CAN’T in-browser JavaScript do?
    • What makes JavaScript unique?
    • Languages “over” JavaScript
    • Summary

An Introduction to JavaScript

Let’s see what’s so special about JavaScript, what we can achieve with it and which other technologies play well with it.

What is JavaScript?

JavaScript was initially created to “make webpages alive”.

The programs in this language are called scripts. They can be written right in the HTML and execute automatically as the page loads.

Scripts are provided and executed as a plain text. They don’t need a special preparation or a compilation to run.

In this aspect, JavaScript is very different from another language called Java.

Why JavaScript?

When JavaScript was created, it initially had another name: “LiveScript”. But Java language was very popular at that time, so it was decided that positioning a new language as a “younger brother” of Java would help.

But as it evolved, JavaScript became a fully independent language, with its own specification called ECMAScript, and now it has no relation to Java at all.

At present, JavaScript can execute not only in the browser, but also on the server, or actually on any device where there exists a special program called the JavaScript engine.

The browser has an embedded engine, sometimes it’s also called a “JavaScript virtual machine”.

Different engines have different “codenames”, for example:

  • V8 – in Chrome and Opera.
  • SpiderMonkey – in Firefox.
  • …There are other codenames like “Trident”, “Chakra” for different versions of IE, “ChakraCore” for Microsoft Edge, “Nitro” and “SquirrelFish” for Safari etc.

The terms above are good to remember, because they are used in developer articles on the internet. We’ll use them too. For instance, if “a feature X is supported by V8”, then it probably works in Chrome and Opera.

How engines work?

Engines are complicated. But the basics are easy.

  1. The engine (embedded if it’s a browser) reads (“parses”) the script.
  2. Then it converts (“compiles”) the script to the machine language.
  3. And then the machine code runs, pretty fast.

The engine applies optimizations on every stage of the process. It even watches the compiled script as it runs, analyzes the data that flows through it and applies optimizations to the machine code based on that knowledge. At the end, scripts are quite fast.

What can in-browser JavaScript do?

The modern JavaScript is a “safe” programming language. It does not provide low-level access to memory or CPU, because it was initially created for browsers which do not require it.

The capabilities greatly depend on the environment that runs JavaScript. For instance, Node.JS supports functions that allow JavaScript to read/write arbitrary files, perform network requests etc.

In-browser JavaScript can do everything related to webpage manipulation, interaction with the user and the webserver.

For instance, in-browser JavaScript is able to:

  • Add new HTML to the page, change the existing content, modify styles.
  • React to user actions, run on mouse clicks, pointer movements, key presses.
  • Send requests over the network to remote servers, download and upload files (so-called AJAX and COMET technologies).
  • Get and set cookies, ask questions to the visitor, show messages.
  • Remember the data on the client-side (“local storage”).

What CAN’T in-browser JavaScript do?

JavaScript’s abilities in the browser are limited for the sake of the user’s safety. The aim is to prevent an evil webpage from accessing private information or harming the user’s data.

The examples of such restrictions are:

  • JavaScript on a webpage may not read/write arbitrary files on the hard disk, copy them or execute programs. It has no direct access to OS system functions.Modern browsers allow it to work with files, but the access is limited and only provided if the user does certain actions, like “dropping” a file into a browser window or selecting it via an <input> tag.

    There are ways to interact with camera/microphone and other devices, but they require a user’s explicit permission. So a JavaScript-enabled page may not sneakily enable a web-camera, observe the surroundings and send the information to the NSA.

  • Different tabs/windows generally do not know about each other. Sometimes they do, for example when one window uses JavaScript to open the other one. But even in this case, JavaScript from one page may not access the other if they come from different sites (from a different domain, protocol or port).This is called the “Same Origin Policy”. To work around that, both pages must contain a special JavaScript code that handles data exchange.

    The limitation is again for user’s safety. A page from http://anysite.com which a user has opened must not be able to access another browser tab with the URL http://gmail.com and steal information from there.

  • JavaScript can easily communicate over the net to the server where the current page came from. But its ability to receive data from other sites/domains is crippled. Though possible, it requires explicit agreement (expressed in HTTP headers) from the remote side. Once again, that’s safety limitations.

JavaScript 2

Such limits do not exist if JavaScript is used outside of the browser, for example on a server. Modern browsers also allow installing plugin/extensions which may get extended permissions.

What makes JavaScript unique?

There are at least three great things about JavaScript:

  • Full integration with HTML/CSS.
  • Simple things done simply.
  • Supported by all major browsers and enabled by default.

Combined, these three things exist only in JavaScript and no other browser technology.

That’s what makes JavaScript unique. That’s why it’s the most widespread tool to create browser interfaces.

While planning to learn a new technology, it’s beneficial to check its perspectives. So let’s move on to the modern trends that include new languages and browser abilities.

Languages “over” JavaScript

The syntax of JavaScript does not suit everyone’s needs. Different people want different features.

That’s to be expected, because projects and requirements are different for everyone.

So recently a plethora of new languages appeared, which are transpiled (converted) to JavaScript before they run in the browser.

Modern tools make the transpilation very fast and transparent, actually allowing developers to code in another language and autoconverting it “under the hood”.

Examples of such languages:

  • CoffeeScript is a “syntactic sugar” for JavaScript, it introduces shorter syntax, allowing to write more precise and clear code. Usually Ruby devs like it.
  • TypeScript is concentrated on adding “strict data typing”, to simplify development and support of complex systems. It is developed by Microsoft.
  • Dart is a standalone language that has its own engine that runs in non-browser environments (like mobile apps). It was initially offered by Google as a replacement for JavaScript, but as of now, browsers require it to be transpiled to JavaScript just like the ones above.

There are more. Of course even if we use one of those languages, we should also know JavaScript, to really understand what we’re doing.

Summary

  • JavaScript was initially created as a browser-only language, but now it is used in many other environments as well.
  • At this moment, JavaScript has a unique position as the most widely-adopted browser language with full integration with HTML/CSS.
  • There are many languages that get “transpiled” to JavaScript and provide certain features. It is recommended to take a look at them, at least briefly, after mastering JavaScript.
Content Protection by DMCA.com
Web Guide, Developer Guide, Guest posts Tags:javascript

Post navigation

Previous Post: When the music is On, Code Snippets Dances too
Next Post: WordPress – Build your personal blog/site in minutes

Related Posts

  • Easy to use AI image generator Banner
    3 Easy-to-Use AI Image Generator: A Sure Way to Artistic Photos Web Guide
  • Benefits of Providing Cyber Security Training to Your Employees Banner
    13 Benefits of Providing Cyber Security Training to Employees Emerging Startups
  • Text Editors For Code - 2018 4
    Text Editors For Code – 2018 Developer Guide
  • Banner image for how to deploy a static react app on Akash Decloud Network
    Easily Deploy a Static React App on Akash Network Cloud Developer Guide
  • Best Headless CMS examples
    Top 5 Best Headless CMS in 2022 Developer Guide
  • 7 Best Blog You must Visit 5
    7 Best Blog You must Visit Web Guide

Comments (2) on “JavaScript”

  1. Shela Gravitz says:
    April 2, 2020 at 9:43 pm

    tҺe website іѕ really good, I really like your blog!

    Reply
    1. Balvinder Singh says:
      April 2, 2020 at 9:45 pm

      Thanks, check other posts. Keep visiting

      Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Advertisements

Subscribe to updates

Enter your email below to subscribe





Posts by Categories

Advertisements
  • 5 great Online Vocabulary Tools you must know banner
    5 Great Online Vocabulary Tools you must know in 2022 Web Guide
  • Top Linux Distros - 2018 | Tekraze 6
    Top Linux Distros – 2018 | Tekraze Developer Guide
  • 5 factors that are slowing down your internet tekraze
    5 Factors That Are Slowing Down Your Internet Guest posts
  • An Introduction to Application Programming Interfaces (APIs) and Common Apps/Services That Use Them
    An Introduction to Application Programming Interfaces (APIs) and Common Apps Services That Use Them Developer Guide
  • Softwares for Building Website Tekraze
    Softwares for Building Website in minutes Web Guide
  • Types of Programming - Difference you need to know 7
    Types of Programming – Difference you need to know Developer Guide
  • Social Media Influencing Apps for mobile tekraze
    Social Media Influencing apps for mobile to try Tech News
  • Linux Terminology basics you need to know
    Developer Terminology – you need to know Developer Guide

Affliate Links

Sell with Payhip

Earn with Magenet

Sell and Buy with Adsy

GainRock affiliate Program

Automatic Backlinks

Advertise with Anonymous Ads

accessily tekraze verificationIndian Blog Directory

Copyright © 2023 Tekraze.

Powered by PressBook News WordPress theme