JavaScript biodata

Estimated reading time: 2 minutes

jasvascript

Jasvascript is scripting language which alive the html. it’s first name was liveScript . that time java was more popular so named JavaScript. Now no relation with java . javascript - echmaScript age with Node.js

adding javascript

  • external
<!DOCTYPE html>
  <html>
      <head>
          <title>code4mk.org</title>
      </head>
      <body>
          <!-- external javascript here -->
          <script src="code4mk.js"></script>
      </body>
  </html>
  • internal
<!DOCTYPE html>
  <html>
      <head>
          <title>code4mk.org</title>
      </head>
      <body>
          <!-- external javascript here -->
          <script type="text/javascript">
            console.log('This is internal JS');
          </script>

      </body>
  </html>

comments

~ comments use for explaining the code

  • single line comment //
// this is single line comment
  • multi-line comment /*...*/
/* this is
   multi-line comment */

string

  • string represent by double quote " " or single quote ' '
var name = 'kamal';
var users = "code4mk";

variable

  • var
  • let
  • const

scope

scope is a area or block . it is related with accesing variable .

global

  • access variable any-where as your desired
 let name = 'kamal';
 let users = () => {
   console.log(name);
 }
 users();
 // kamal

local

  • can access only insdie of scope or block or that function
  • can’t access outside of the block .
let users = () => {
  let name = 'kamal';
}
users();
console.log(kamal);
// Uncaught ReferenceError: kamal is not defined
js