diff --git a/JavascriptFundamentalsInBrief.js b/JavascriptFundamentalsInBrief.js new file mode 100644 index 00000000..dd0377cf --- /dev/null +++ b/JavascriptFundamentalsInBrief.js @@ -0,0 +1,160 @@ +console.log(document) //this document is a object that is responsible to connect html with javascript so that +//our web page will function accordingly(javascript can control html by this document which is written in c++, +//c++is relatively a low level langauge than c++). +//DOM stands for document object model,when we load a page,the server sends the html code to the browser,then the browser needs to report two things,css and javascript +//css for designing and js for interactivity but before they dov their work browser needs to make a tree like structure of html for them such that +//css and js can work on the nodes they required to, quickly. +//that tree like structure is called DOM +//DOM is a programmatic representation of html made by browser and it is the view of what we see on the screen +//if remove an element form DOM thennit will not appear on the screen and vice versa. +//so js can mainpulate the DOM + +//document.querySelector +const heading=document.querySelector('h1') //single or double quotes both can be used,here inside queryselector, +//we can write anything that can be written inside css selector like id and class. +console.log(heading) //text inside h2 will apear on console +heading.innerText="hi this is sapna" //by using this property we can change the text of any selected element(single and double quotes) +console.log(heading) //after changing the text ,new text will appear on console,but the upper line will also reflect the new text then. +const listitems=document.querySelector('ul li') +console.log(listitems) //nut this will only give 1st list item bcz in js it search for the element that is in ul li and return +//so its diffrent from css bcz css will be applied to all the element of ul li +//so to aplly js in all the elements we can use all +const listt=document.querySelectorAll('ul li') +console.log(listt) //it will return nodelist of all the list items +//nodelist can be understandable as array though it snot exctlhy an array +//we can iterate in it just like array +for(let i=0;i{ + +} +arrowFunc() //function call for array func after declaration wiill not give error as understood +//a speaciality of array func is that e need not to write its definition inside the cruly braces unlike conventional function +const vv=()=>2 +console.log(vv()) //will return 2 +//or +const vw=(arg)=>arg**2 //we need not to write return explicitly here,but if we use curly braces then we need to writ ereturn there +//we can also write single argument without braces,but in case of multiple arguments ,we must write it within braces otherwise it will not work. +console.log(vw(2)) //will return 4 + + + +//new array methods inES6