Showing posts with label JavaScript. Show all posts
Showing posts with label JavaScript. Show all posts

Mention the functionality which you can do with JavaScript

Given below are the things which you can do with JavaScript:
  1. Give response to a user instantaneously – Suppose a user has just submitted a comment form on your website. It would be a nice idea to show a thank you message to the user instantaneously using JavaScript. The server can also do this but it might take a little while for your thank you message to appear to the user, depending on how busy the server is.
  2. Make your web pages responsive to events – Since Web environments are dynamic, events happen all the time. With JavaScript, the web page can immediately react to these events the way you choose.
  3. Detect visitors browser – JavaScript can be used to detect a visitor's browser. You can choose to load a page specifically tailored to that kind of browser, depending on the browser and its capabilities.
  4. Creation of Cookies – JavaScript is quite efficient if you want to create cookies so that your visitors can enjoy a personalized experience the next time they visit your website.
  5. Validation of Web Form data – JavaScript can be used to validate web-form data before the form is submitted to a server. This saves the server from extra processing.
  6. There are tons of other functionality which can be implemented by JavaScript such as addition of cool animation effects to your web pages without using an external Flash plug-in, usage of the newest features of HTML5 such as canvas (to draw directly on your web page) and drag and drop capabilities, integrate your website with external web services such as Facebook, Twitter, etc.

Mention the functionality which you cannot do with JavaScript

Given below are the things which you cannot do with JavaScript:
  1. JavaScript cannot be forced onto a browser. Since JavaScript runs on client-side, the user has control over it. He can disable JavaScript on his browser or use older version of the browser in which case, JavaScript will not not work.
  2. Same Origin PolicyResources cannot be accessed or modified from another Internet domain with JavaScript, which is known as Same Origin Policy. The JavaScript script can only access resources on the same website.
  3. Server resources (such as databases) cannot be accessed with JavaScript. Since it is a client-side language, it's limited to what can be done on the client.

What is JavaScript?

JavaScript is a high-level, dynamic, untyped interpreted programming language. It is a scripting language (a lightweight programming language) that is interpreted by the browser engine when the web page is loaded. It was designed primarily to add interactivity to Web pages and Web applications. The language was first implemented by Netscape Communications Corp. in Netscape Navigator 2 beta (1995). 
 
JavaScript is different from Java (developed in the 1990s at Sun Microsystems). Java is a powerful and much more complex programming language in the same category as C and C++. JavaScript was created by Brendan Eich at Netscape and was first introduced in December 1995 under the name of LiveScript. Later, it was renamed to JavaScript, although JavaScript’s official name is ECMAScript, which is developed and maintained by the ECMA (European Computer Manufacturer's Association) International organization. However, the two languages can inter-operate well.

Client-side JavaScript programs, or scripts, can be embedded directly in HTML source of Web pages. (Note: There is also server-side JavaScript.) Depending on the Web developer's intent, script code may run when the user opens the Web page, clicks or drags some page element with the mouse, types something on the keyboard, submits a form, or leaves the page. The fact that the JavaScript interpreter is the browser engine itself accounts for some inconsistencies in the way your JavaScript-powered page might behave in different browsers. But well-established techniques and powerful JavaScript libraries such as jQuery makes things wonderfully easier. 
 
JavaScript is an object-oriented language with prototypal inheritance (in a prototypal system, objects inherit from objects). The language supports several built-in objects, and programmers can create or delete their own objects. Prototypal inheritance makes JavaScript very different from other popular programming languages such as C++, C#, or Java featuring classes and classical inheritance. JavaScript does not have classes as in C++ or Java, however, objects can inherit properties directly from each other, forming the object prototype chain. 
 
JavaScript is an interpreted language, with optional JIT-compilation support. In older implementations (e.g. Internet Exlorer 8 and earlier, Firefox prior to 3.5), JavaScript was a purely interpreted language, which means that scripts execute without preliminary compilation, i.e. without conversion of the script text into system-dependent machine code. The user's browser interprets the script (analyzes and immediately executes it).

In modern implementations, JavaScript code may be either interpreted or compiled using a just-in-time (JIT) compiler. At run time, the browser decides whether (parts of) script code should be JIT-compiled for better performance. This makes JavaScript significantly faster and therefore more suitable for complex performance-demanding Web applications. JavaScript is widely supported and recent versions of all popular browsers have JavaScript JIT-compilers.