Lesson-4-JavacscriptBasics.ppt - Lesson 4 JavaScript Basics 1 What is JavaScript \u2022 JavaScript is a dynamic computer programming language \u2022 \u2022 It is

Lesson-4-JavacscriptBasics.ppt - Lesson 4 JavaScript Basics...

This preview shows page 1 - 14 out of 64 pages.

1 Lesson 4 JavaScript Basics
Image of page 1
What is JavaScript ? JavaScript is a dynamic computer programming language. It is lightweight and most commonly used as a part of web pages, whose implementations allow client-side script to interact with the user and make dynamic pages. It is an interpreted programming language with object-oriented capabilities. 02/24/20 2
Image of page 2
Why Use JavaScript? At present, JavaScript can execute not only in the browser, but also on the server or actually on any device where there exists a special program called the JavaScript engine. The browser has an embedded engine, sometimes it’s also called a “JavaScript virtual machine”. Different engines have different “codenames”, for example: 02/24/20 3
Image of page 3
JavaScript Engines V8 – in Chrome and Opera. Spider Monkey – in Firefox. ChakraCore” for Microsoft Edge. Nitro” and “SquirrelFish” for Safari etc. 02/24/20 4
Image of page 4
How JavaScript Engines Work Engines are complicated. But the basics are easy. The engine (embedded if it’s a browser) reads (“parses”) the script. Then it converts (“compiles”) the script to the machine language. And then the machine code runs quite fast. 02/24/20 5
Image of page 5
What can JavaScript Do? In-browser JavaScript can do everything related to webpage manipulation, interaction with the user and the webserver. 02/24/20 6
Image of page 6
JavaScript Can Add new HTML to the page, change the existing content, modify styles . React to user actions, run on mouse clicks . Remember the data on the client-side (“local storage”). 02/24/20 7
Image of page 7
JavaScript vs HTML vs CSS 02/24/20 8 JavaScript is one of the 3 languages all web developers must learn: HTML to define the content of web pages CSS to specify the layout of web pages JavaScript to program the behavior of web pages
Image of page 8
JavaScript vs Java JAVA JAVASCRIPT Is strongly typed language and variable must be declare first to use in program. I s weakly typed language and have more relaxed syntax and rules. Program has file extension “.Java” and translates source code into bytecodes which is executed by JVM(Java Virtual Machine). File has file extension “.js” and it is interpreted but not compiled. Every browser has the JavaScript interpreter to execute JS code. Is a Standalone language. Contained within a web page and integrates with its HTML content. Program uses more memory. Requires less memory therefore it is used in web JavaScript and Java are completely different languages, both in concept and design.
Image of page 9
JavaScript Syntax JavaScript syntax is the set of rules, showing how JavaScript programs are constructed: modern <script ...> JavaScript code </script> old <script language="javascript" type="text/javascript"> JavaScript code </script> 02/24/20 10
Image of page 10
JavaScript Syntax(cont.) var x, y, z; // How to declare variables x = 5 ; y = 6 ; // How to assign values z = x + y; // How to compute values 02/24/20 11
Image of page 11
JavaScript Data Types 02/24/20 12 JavaScript variables can hold many data types : numbers, arrays, null, strings, objects a nd more: var length = 16 ; // Number var lastName = "Johnson" ; // String var x = {firstName: "John" , lastName: "Doe" }; // Object
Image of page 12
JavaScript Values 02/24/20 13
Image of page 13
Image of page 14

You've reached the end of your free preview.

Want to read all 64 pages?

  • Fall '19
  • Document Object Model

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

Stuck? We have tutors online 24/7 who can help you get unstuck.
A+ icon
Ask Expert Tutors You can ask You can ask You can ask (will expire )
Answers in as fast as 15 minutes