JS: JavaScript Tutorial: Learn & Clear JS Concepts with to-the-point approach | JavaScript
JavaScript Introuction
Learn JavaScript (JS), the most popular client-sdie lenaguage on the web for decades. JavaScript tutorial with examples and the code explaination, tips & tricks to write efficient code for JavaScript. Tutorial also works great for QA Engineers for testing purpose.
What is JavaScript
JavaScript (JS) is a high-level programming language that conforms to the ECMAScript specifications to make web page dynamic.Why JavaScript
JavaScript makes a web page dynamic. JavaScript is the one of the basic languages a Web Developer or User Interaface (UI) Developer must learn:
- HTML (Hyper Text Markup Language)
- CSS (Cascading Style Sheet)
- JavaScript
JavaScript usage
JavaScript can be used at client-side as well as at server-side.
While using examples in this tutorial, please press F12 in your Web Browser to open developers' tools and choose the Console tab.
Client-Side
JavaScript can be used on a web-page with JavaScript inline code, on-page code or seperate file code
JavaScript inline code
<html>
<body>
<button onclick="alert('button clicked')">Test Button</button>
</body>
</html>
JavaScript in script tag
<html>
<body>
<button onclick="test()">Test Button</button>
<script type="text/javascript">
function test(){
alert('button clicked');
}
</script>
</body>
</html>
JavaScript in seperate file
function test(){
alert("tested");
}
<html>
<body>
<button onclick="test()">Test Button</button>
<script type="text/javascript" src="test.js"></script>
</body>
</html>
Server-Side
JavaScript can be used for server-side developement like node.js.
When JavaScript Introduced (history)
JavaScript was developed by Brendan Eich in 1995 for Netscape Navigator to make the website dynamic.
LiveScript is the old name of JavaScript.
Where JavaScript
JavaScript is being successfully used on client-side HTML web pages as well as at server-side developement, Nod.js is the prominent example.
JavaScript file extension
.js is the file extension used for a JavaScript file. .js file extension is used for both, web-page script as well as server-side (e.g. Node.js) files.
JavaScript Engine
JavaScript code/files are executed by run-time engines. For exampe, V8 is the JavaScript engine used by Google Chrome and Node.js.
JavaScript compiled or interpreted
JavaScript code is interpreter, not compiled.
JavaScript case sensitivity
JavaScript is a case-sensitive language. i.e. JavaScript engine treates var a;
and var A;
as different variables.
Notes
- JavaScript is based on ECMAScript (ES) standards with additional features of its own
- JavaScript works on Client-Side web browsers as well as Server-Side
- JavaScript is a loosely type as well as dynamic type programming language
- JavaScript is a case sensitive programming language
- JavaScript is cross platform, i.e. runs on any Operating System including Windows, MacOS, Linux, Ubuntu, Solarix, iOS, Android, Windows Phone etc.