Tuesday, 5 May 2020

INTRODUCTION TO JAVASCRIPT

JavaScript

  • JavaScript is used in millions of Web pages to improve the design, validate forms, detect browsers, create cookies, and much more.
  • JavaScript is the most popular scripting language on the internet, and works in all major browsers, such as Internet Explorer, Mozilla, Firefox, Netscape, Opera.

WHAT IS JAVASCRIPT?

  • JavaScript was designed to add interactivity to HTML pages 
  • JavaScript is a scripting language (a scripting language is a lightweight programming language) 
  • A JavaScript consists of lines of executable computer code 
  • A JavaScript is usually embedded directly into HTML pages 
  • JavaScript is an interpreted language (means that scripts execute without preliminary compilation) 
  • Everyone can use JavaScript without purchasing a license 

Are Java and JavaScript the Same? 

  • NO!
  • Java and JavaScript are two completely different languages in both concept and design!
  • Java (developed by Sun Microsystems) is a powerful and much more complex programming language - in the same category as C and C++.

How to Put a JavaScript Into an HTML Page?

<html>
<body>
<script type="text/javascript">
document.write("Hello World!")
</script>
</body>
</html> 

JavaScript Variables 

  • Variables are used to store data. 
  • A variable is a "container" for information you want to store. A variable's value can change during the script. You can refer to a variable by name to see its value or to change its value.
  • Rules for variable names:
  • Variable names are case sensitive 
  • They must begin with a letter or the underscore character 
  • strname – STRNAME (not same)

Example

<script>
x=“Hello World!”
document.write(x)
</script>

<script>
x=“İsminizi Yazın….”
document.write(“Merhaba” +x)
</script>  use line break html code

JavaScript Popup Boxes 

Alert Box
An alert box is often used if you want to make sure information comes through to the user.
When an alert box pops up, the user will have to click "OK" to proceed. 
<script>
alert("Hello World!")
</script>

<script>
x=prompt (“Adınızı Yazınız”, “ ”)
document.write(“Merhaba <br>”,+x)
</script>

No comments:

Post a Comment

thanks for comment :) this will answer after approval