JavaScript Intro And Basic

Posted by

JavaScript

JS is a part of web page that’s defines all the action perform on the web pages.

JS is a programming language with oop concepts.

JS is simple and easily compatible with HTML And CSS.

HISTORY

JS was founded by BRENDEN EICH

He developed JS in1995.

TOOLS

To work with JS we need two Tools:-

. Text-editor :- Where we write the JavaScript code.

. Browser :- Where our code is execute.

JavaScript First Code

Here we write the first code of JS where we print the ” HELLO WORLD”.

we print the word in console so to do this we have to open the console of the we page

to open the console just press ” ctrl + shift + i”.

After that console is open we have to write JS code in the console to print the word

CODE :-

console.log(“HELLO WORLD”);

console.log is use to print output.

Adding JS to HTML Page

We add JS in HTML through 2 way :-

  1. By adding script tag in the HTML page where the body tag is closing

    Ex –
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <button class="btn">submit</button>
     
</body>
<script>

            console.log("HELLO WORLD");
    
</script>
</html>

2. By including the JS file or folder where we write the JS code.

Ex- By providing the source of the file or path .


<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<script src="inc.js"></script>

<body>
    <button class="btn">submit</button>
     
</body>

</html>


THANKU 🙂