Tutorial Page!
The function statement declares a function. A declared function is "saved for later use", and will be executed later, when it is invoked (called).
In JavaScript, functions are objects, and they have both properties and methods. A function can also be defined using an expression.
function hi(){
console.log('hello');
}
An object is a collection of properties, and a property is an association between a name (or key) and a value.
let garden ={
vegetable: 'zucchini',
flower: 'sunflower',
fruit: 'grape',
water: true,
sun: true,
size: 10,
;
console.log(garden.vegetable);
}
let value ='vegetable';
console.log(garden.value, garden[value]);
console.log(garden.value, garden['vegetable']);
The Array in JavaScript is a global object which contains a list of items. It is similar to any variable, in that you can use it to hold any type of data.
An element inside an array can be of any type, and different elements of the same array can be of different types : string, boolean, even objects or other arrays.
They have [ ], can hold multiple data types, and are good for listing.
let food = ['pecan pie', 'shrimp', 'quesadilla', 'cheese cake', 'hot dog'];
for(let f of food){
console.log(f);
}
food.push('pizza');
console.log(food);///adds a value to the string
food.splice(1, 1, 'bananas');
console.log(food);////replaces original value
food.splice(2,0, 'sweet potato pie');
console.log(food);
food.pop();//remove last added file