First, JavaScript variables
The standard for JS variables
(1) The variable must be in the letter
(2) can start with $ and _ but not recommended
(3) variable-to-case sensitivity
JavaScript declares variables with Var
For example: Var carname= "Volvo";
Value = undefined in a computer program, variables that are not valued are often declared. A variable that is not declared with a value, whose value is actually undefined.
Ii. JavaScript data types
String String Numeric Number Boolean Boolean array of Array Object object
Null null undefined Undefined
JavaScript arrays
var cars = new Array ("Saab", "Volov", "BMW");
var cars = ["Saab", "Volov", "BMW"];
The array subscript is based on the 0
JS Object
Object properties are addressed in two ways:
document.write (person.lastname + "<br>");
document.write (person["LastName"] + "<br>");
Declaring variable types
When you declare a new variable, you can use the keyword "new" to declare its type:
var carname=new String;
var x= new number;
var y= new Boolean;
var cars= new Array;
var person= new Object;
JavaScript variables are objects. When you declare a variable, a new object is created
The lifetime of a JavaScript variable
The lifetime of JavaScript variables begins at the time they are declared.
Local variables are deleted after the function is run.
Global variables are deleted after the page is closed.
Functions of JavaScript
Grammar
function functionname ()
{
Execute code
}
Calling a function with parameters
function functionname (ARGUMENT1,ARGUMENT2)
{
Execute code
}
function with return value
function Myfuntion ()
{
var x=5;
return x;
}
Tomorrow's Content
JS's scope JS event js string js operator js Comparison
"Excellent Boer" JS basic content finishing (2)