• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer
  • Study Abroad
  • Writing Services
  • About Us
  • Contact
  • Blog

AcademicsHQ

Instant access to Study Resources, 24/7 Homework Help, Tutors, to help you ace your homework.

homework help
  • Academic Writing
    • Dissertation Writing
    • Report Writing
  • Research Process
  • Referencing Guide
  • Resume Writing
Home » Blog » INTRODUCTION to JAVASCRIPT

INTRODUCTION to JAVASCRIPT

December 13, 2018 by academicshq Leave a Comment

professional technology programs

Introduction to scripting: overview of Java Script, advantages, client side java Script, capturing user input, writing JavaScript into HTML

Basic JavaScript Techniques: Data types, literals, variables and operators, Java Script arrays, dense array, operators, expressions


GET INSTANT HELP FROM EXPERTS!

  • Looking for any kind of help on your academic work (essay, assignment, project)?
  • Want us to review, proofread or tidy up your work?
  • Want a helping hand so that you can focus on the more important tasks?

Hire us as project guide/assistant. Contact us for more information


Java Script Programming Construct: Assignment, data declaration, if, switch, while, for, do while, label, break, Continue, function call, return, with, delete, method invocation.

Overview of Java Script

JavaScript is an object-based scripting language that is lightweight and cross-platform.
JavaScript is not compiled but translated.
JavaScript Translator (embedded in browser) is responsible to translate the JavaScript code
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.
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

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

Is 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++.

Advantages
An Interpreted Language
Embedded within HTML
Minimal Syntax
Quick development
Designed for simple , small program
Performance
Procedural Capabilities
Designed for Programming User Events
Easy Debugging & Testing
Platform Independence /Architecture Neutral

How to Put a JavaScript Into an HTML Page?

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

Ending Statements With a Semicolon?
With traditional programming languages, like C++ and Java, each code statement has to end with a semicolon (;).
Many programmers continue this habit when writing JavaScript, but in general, semicolons are optional! However, semicolons are required if you want to put more than one statement on a single line.

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)

Data type

Primitive data type
Non-primitive (reference) data type
JavaScript is a dynamic type language, means you don’t need to specify type of the variable because it is dynamically used by JavaScript engine. You need to use var here to specify the data type. It can hold any type of values such as numbers, strings etc.

var a=40;//holding number
var b=“bvimed”;//holding string

Primitive
String represents sequence of characters
e.g. “hello”
Number represents numeric values
e.g. 100
Boolean represents boolean value either
false or true
Undefined represents undefined value
Null represents null i.e. no value at all

Non-primitive
Object represents instance through which we can access members
Array represents group of similar values
RegExp represents regular expression

JavaScript Functions

JavaScript functions are used to perform operations. We can call JavaScript function many times to reuse the code.
Advantage of JavaScript function
Code reusability: We can call a function several times so it save coding.
Less coding: It makes our program compact. We don’t need to write many lines of code each time to perform a common task.
Syntax
function functionName([arg1, arg2, …argN]){
//code to be executed
}

JavaScript Function Example
function in JavaScript that does not has arguments.
<script>
function msg()
{
alert(“hello! this is message”);
}
</script>

Recursion in JavaScript
function factorial( n )
{ if ( n === 1 )
{ return 1; }
return n * factorial( n – 1 );
}
factorial of a number n is the product of all positive integers less than or equal to n. In other words
The factorial of 5 is 5 x 4 x 3 x 2 x 1. The mathematical notation for this is 5!.

JavaScript Variable Scope
The scope of a variable is the region of your program in which it is defined.
JavaScript variables have only two scopes.

Global Variables: A global variable has global scope which means it can be defined anywhere in your JavaScript code.

Local Variables: A local variable will be visible only within a function where it is defined. Function parameters are always local to that function.

Nested Functions
Prior to JavaScript 1.2, function definition was allowed only in top level global code, but JavaScript 1.2 allows function definitions to be nested within other functions as well.

<script type=”text/javascript”>
function concatenate(first, last)
{
var full;
full = first + last;
return full;
}
function secondFunction()
{
var result;
result = concatenate(‘Zara’, ‘Ali’);
document.write (result );
}
</script>

Function () Constructor
The function statement is not the only way to define a new function; you can define your function dynamically using Function() constructor along with the new operator

<script type=”text/javascript”<
var variablename = new Function(Arg1, Arg2…, “Function Body”);
</script<
Notice that the Function() constructor is not passed any argument thatspecifies a name for the function it creates. The unnamed functions createdwith the Function() constructor are called anonymous functions.

JavaScript 1.2 introduces the concept of function literals which is another new way of defining functions. A function literal is an expression that defines an unnamed function.
Syntax
The syntax for a function literal is much like a function statement, except that it is used as an expression rather than a statement and no function name is required
<script type=”text/javascript”>
var variablename = functin(Argumeont List){
Function Body
};
</script>

What is an Event?
JavaScript’s interaction with HTML is handled through events that occur when the user or the browser manipulates a page.
When the page loads, it is called an event.
When the user clicks a button, that click too is an event. Other examples include events like pressing any key,closing a window, resizing a window, etc.
Developers can use these events to execute JavaScript coded responses, which cause buttons to close windows, messages to be displayed to users, data to be validated, and virtually any other type of response imaginable.

onclick Event Type
This is the most frequently used event type which occurs when a user clicks the left button of his mouse. You can put your validation, warning etc., against this event type

onsubmit Event Type
onsubmit is an event that occurs when you try to submit a form. You can put your form validation against this event type.

onmouseover and onmouseout
The onmouseover event triggers when you bring your mouse overany element and the onmouseout triggers when you move your mouse outfrom that element

Filed Under: Computers

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *


Primary Sidebar

Recent Posts

  • Hindi Project Work: Hindi Pariyojana Karya (हिंदी परियोजना कार्य)
  • Geography Projects Class 10
  • Money Education for Kids: Teach Them Financial Responsibility
  • Bachelor of Management Studies (BMS): Project Work
  • BMS (Bachelor of Management Studies): Assignment & Project Topics

Categories

  • Black Book Projects
  • Book Reviews
  • Business Law
  • CBSE Study Notes
  • Computers
  • Digital Business
  • Economics
  • Education Articles
  • English Literature
  • Environmental
  • Essays
  • Foreign Education
  • General
  • Geography
  • German
  • Global Education
  • Hindi
  • History
  • Hotel Management
  • HRM
  • Jobs
  • Management
  • Management Notes
  • Math
  • Media Study Notes
  • Movie Reviews
  • Primary
  • Research
  • Sample Essays
  • School Projects
  • School Study Notes
  • Science
  • Self Improvement
  • Services
  • Social Studies
  • Sociology
  • Solved Assignments
  • Student Software
  • Uncategorized
  • Writing Tips

Footer

CLASS NOTES

  • Class 10 . Class 9
  • Class 8 . Class 7
  • Class 6 . Class 5
  • Class 4 . Class 2
  • Class 2 . Class 1

ACADEMIC HELP

  • Essay Writing
  • Assignment Writing
  • Dissertation Writing
  • Thesis Writing
  • Capstone Projects
  • Homework Help
  • Report Writing

SERVICES

  • Writing Services
  • Book Review
  • Ghost Writing
  • Make Resume/CV

ABOUT US

  • About Us
  • Contact
  • Privacy Policy
  • Blog

Copyright © 2025 · News Pro on Genesis Framework · WordPress · Log in