// CLASS TOPICS : FEW METHOD OF Array DATA TYPES
// reverse
// list = ["a","b","c","d"].reverse();
// console.log(list);
// it will reverse the array whether it is array of string, number whatever
// Pop
// list = [1,2,3,4];
// list.pop();
// console.log(list);
// it will remove the last element from array
// why we are writing .pop in next line?
// because pop will remove last element from orignal array it is going to return only the elemet it is removing not a new array.
// if we write list = [1,2,3,4].pop() then as i said it will return last element that is 4
// Slice
// list = [1,2,3,4,5].slice(0,4)
// console.log(list);
// same as in string
// To string
// list = [1,2,3,4].toString()
// console.log(list,typeof(list));
// convert array to a string
// Concat
// list = [1,2,3,4,5].concat(["a","B","c"],["d","e"])
// console.log(list);
// merge two or more arrays
// CLASS TOPICS : Object DATA TYPE // myValue = {name:"shagun", age:23,email:"info@codesikho.com"} // console.log(myValue); // object is written using {} symbol // we will write our key:value pair between {} separated by , // value maybe a string , array or a object or maybe a number // HOW TO ACCESS VALUES? // myValue = {name:"shagun", age:23,email:"info@codesikho.com"} // myKeyVal= myValue["email"] // myKeyVal = myValue.age // console.log(myKeyVal); // so we can access either entering key name between [] in a string format // or we can access using . and then key name // we cannot write value with same key otherwise it will get override // myValue = {name:"shagun",name:"abc"} // console.log(myValue.name);
Comments
Post a Comment