Js Code With Harry
Js Code With Harry
Js Code With Harry
.toUpperCase()
.replace(“huzaifga”,”Huzaifa”)
.tostring();
.join(“-”)
.delete[i];
.concat[a,b,c,d,e]
For(let I of num){
Console.log(i);
num.map((value,index,array)=>{
console.log(value,index,array);
})
FILTER METHOD:
.reduce() will add the elements of array
Console methods:
Conclose.error(“this will print in red form”)
Console,warn(“”)
Conso;e.infro()
Console.time(label)
Console.timeEnd(label)
document.write(a);
confirm:
gives short message with ye or no option this will return true for yes and false for no
location.href=https://google.com
typeof document.title
meta tag:
meta tag is child of head
document.element.childNodes()
elem.hasChildnodes()
b.firstElementChild
tables:
document.body.firstElement.child.firstElementChild
DOM:
Ctitle.style.color=”red”
GetElementByTagName(“s”)
Matches,closestand contains:
Console.logid1.matches(“.class”)
Element.closest(css)
Chapter 8
Console.dir will print as an object with its properties
>innerHTML will return inner part odf document and .innerHTML will be used to replace the text in the
old html valid only for element nodes
outerHTML
let a =idname.getAttribute(“class”) // this will print the class name with respected id.
let a =idname.hasAttribute(“class”) // we will find that if this id has attribute class or not
element.setAttribute(“class”,”hidden”)
element.removeAttribute(“class”)
let a = document.getElementByTagName(‘div’)[0]
a.appendChild(div)
alert("hello");
let a= setTimeout(function(){
},2000)
console.log(a);
dom events:
<body>
</div>
<script src="script.js"></script>
Onmouseenter:
<body>
<div class ="container" onmouseenter="alert('mouse inside container')">
</div>
Onclick
})
Promise.then((value)=>{
Console.log(value)
})
Promise API:
6 primary method:
First method if all promises are resolved then it will give final result but incase any one is not resolved
then this will not proceed
Promise_all.then((value)=>{
Promise_all.then((value)=>{
Async Await:
We can put our code to run
Colsole.log(Rahul)
Catch(error){
Console.log(error)
Error.name
Finally{
This piece of code inside finally block will execute under anycondition