Why javascript?
HTML and CSS make the web awesome. But to add some additional functionality to increase interactivity in web pages. JavaScript was created by Brendan Eich in 1995 while he was working at Netscape Communications Corporation. Initially it was named as mocha but later it was renamed as livescript but to increase marketing purpose they renamed it as JavaScript. Later it was adapted by all browser
What is javascript?
It is a scripting language. It is a dynamically typed programming language. It interprets the code in the browser and gives the output in the Browsers console. Is there any other place we can be able to run the javascript.
how we can add javascript to the web pages.
We can add it just like the style sheet but with different tag. This time we are using a script tag to add javascript’s interactive script along with html. Another one, an American software engineer has an induction on how to run javascript in computers. He takes the chrome browsers javascript V8 engine and adds the environment in the computer actually it word and without relaying the browsers those who all are interested running JavaScript in native nodejs will help them. But it will work without the browsers interactions.
Type safety
javascript is dynamically typed and it causes many issues in the larger codes, so Microsoft invented the Typescript, it compiles the statically typed typescript program into save javascript program.
ECMAScript
It was created in 1995 by the Netscape, because of its impression and interactivity competitors like Microsoft and others developed their version of the Javascript, it forces the developer to write their own version of code to service the business all the browsers. To resolve the issue Netscape submitted the language to Ecma International in 1997 to create a universal standard. They named the standard ECMAScript due to trademark issues with the word "JavaScript".
Example:
<script src=”main.js” ><script>
src is the attribute used to locate the source file of the JavaScript code.
Otherwise
we can add the javascript directly to the html file using script tag
example:
<script>
// what ever we write here it will start executing javascript code
</script>
hello world
printing “Hello world!” is the convention of learning a new programming language. How to do it in JavaScript.
<script>
console.log(“Hello world!”)
</script>
or otherwise we can include it by scriptfile
//helloworld.js
console.log(“Hello world!”)
//index.html
<script src="helloworld.js” ><script>
it will give the output in the Browser console log
shell we run the javscript the nativelly, we will run it by
$ node helloworld.js
//helloworld.js
console.log(“Hello world!”)
running the typescript file
$tsc helloworld.js
//helloworld.js
console.log(“Hello world!”)
Other than this run time environment there are some other types. For example Deno, bun. Deno is written entirely in rust to the node's complexities and Bun is written completely in new programming language zig. Zig out performs all this runtimes
Data Types
According to the ECMAScript standards JavaScript has eight built- in datatypes. This eight data type is divided into two types. There types are divided into two main categories : primitive data type and another one is non-primitive data type.
To run Deno
$deno filename.js
To run Bun
$bun filename.js
The primitive data type has seven types and the non-primitive data type has one type.
Primitive data type
- String
- Number
- BigInt
- Boolean
- Undefined
- Null
- Symbol
And the non-primitive type
- Object
Top comments (0)