0% found this document useful (0 votes)
165 views7 pages

JavaScript Basics and Sample Codes

JavaScript is a scripting language that is interpreted within browsers to provide user interactivity on web pages. It can be used for both client-side scripting in browsers or server-side scripting. JavaScript is object-based, platform independent if the browser supports it, and uses various operators, variables naming rules, and sample code examples to demonstrate programming concepts like alerts and prompts.

Uploaded by

api-26450504
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
165 views7 pages

JavaScript Basics and Sample Codes

JavaScript is a scripting language that is interpreted within browsers to provide user interactivity on web pages. It can be used for both client-side scripting in browsers or server-side scripting. JavaScript is object-based, platform independent if the browser supports it, and uses various operators, variables naming rules, and sample code examples to demonstrate programming concepts like alerts and prompts.

Uploaded by

api-26450504
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd

CS114 INTRODUCTION TO JAVASCRIPT

1.0 Introduction to JavaScript


• Is a scripting language

• Interpreted from within a browser.

• Available in two formats : client-side JavaScript and server-


side JavaScript.

• It is an object-based language that comes with many built-in


objects.

• Is platform-independent as long as the browser is


JavaScript-enabled.

• Is designed to extend the capabilities of the Web


application to provide user interactivity.

5-1
INTRODUCTION TO JAVASCRIPT CS114

2.0 Keywords in JavaScript

3.0 Rules to follow when naming variables :

5-2
CS114 INTRODUCTION TO JAVASCRIPT

• The name must begin with a letter or an underscore.

• The rest of the name is made up of letters, numbers, or


underscores.

• Do not use the reserved words in JavaScript.

• Avoid placing any spaces or punctuation in the name.


VALID INVALID
mynumber my number (space)
student_no student.no (period)
male *male (must start with a number)
year2001 2001 (must start with a number)

4.0 Operators in JavaScript


symbol description
= Assign values
+ Addition
- Subtraction
* Multiplication
/ Division
% Modulus
- returns the remainder
++ Increments by one
-- Decrements by one
== equals
!= not equal to
> greater than
< less than
>= greater than or equal to
<= less than or equal to
&& logical AND
|| logical OR

5.0 Hello World Program

5-3
INTRODUCTION TO JAVASCRIPT CS114

6.0 Window Alert

7.0 Window Prompt

5-4
CS114 INTRODUCTION TO JAVASCRIPT

8.0 Sample Codes 1

9.0 Sample Codes 2

5-5
INTRODUCTION TO JAVASCRIPT CS114

10.0 Sample Codes 3

11.0 Sample Codes 4

5-6
CS114 INTRODUCTION TO JAVASCRIPT

5-7

You might also like