Javascript Basics (Assignment 1)
Javascript Basics (Assignment 1)
export
return
case
for
switch
comment
function
this
continue
if
typeof
default
import
var
delete
in
void
do
label
while
else
new
with
3.document object
document.write object is used to print something in webpage, its same like
printf in C programming.
if we write document.write(Hello! How Are You?);
it will print
Hello! How Are You?
4.Local Variables and Global Variables
Local variable : Local variable is which we can use only for certain program
and it cant be used for any other program lets see a example to clarify this.
Like we have a function which has two variable x and y
inside it so if we want to run it it will run undoubtlly, but if we want to use
them anywhere else it will not response or run and these are called local
variables.
but if we had taken the
function add(){
x = 5;
y = 3;
sum = x + y;
return sum
}
document.write(add());
But if we had taken those two variables outside the function, those variable
would had been working for that function and even if we wanted to call those
variables for other tasks to perform they would do that,so as they are doing
everyones tasks they are called global variables .
Var x = 96;
Var y = 54;
function add(){
sum = x + y;
return sum
}
document.write(add());
5. Conditions of Variables
The general rules for constructing names for variables (unique identifiers)
are:
6.Object
Objects are variables too. But objects can contain many values.
We use object JS like this
var car = {type:"Fiat", model:500, color:"white"};
7. Concatenation
Concatenation is a way to add strings, numbers, arrays etc in one statement easily
in JS.
A simple example:
firstName = "Rifat";
age = 27;
country = "Dhaka";
brother = "Rahat";
designation = "Mentor";
company = "Coderstrust";
classStart = 3;
year = 2015;
space = "";