Dev.to WebDev 🛠 Dev 👁 0 📖 2 min read

API, Promise, DOM

API - Application Programming Interface which is used to communicate between two software over the internet. API Calling fetch(url) .then((res) => res.json()) .then((data) here th

API, Promise, DOM

API - Application Programming Interface which is used to communicate between two software over the internet.

API Calling

        fetch(url)
            .then((res) => res.json())
            .then((data)

here the fetch is fetching API url and convert the data into json

->JSON(Javascript Object Notation) - transmitting data between a server and a web application, text based and human readable format.

PROMISE

It act as an asynchronous result operations like success, rejected.
-> if the condition is success(.then)
-> if the cond is rejected(.catch)

DOM
-> Document Object Model is a programming interface that represents an HTML document as a tree of objects.

eg:
Document
│
(Root)
│
┌────────┴────────┐
│ │

│ │

┌──────┴──────┐<br> │ │<br> <h1> <a> (Link)</p> <p>these are called their are plenty of events<br> onClick()<br> dblclick()</p> <p>function changeTxt(){<br> const ele = document.getElementById("title").innerText="hello"</p> <p>the <strong>innerText</strong> helps to changes your text.</p> <p>document.createElement -> here you can create an element like document.createElement(div) , document.createElement(h1) </p> <p><strong>localStorage</strong></p> <p>localStorage -> built in web storage object in js that allows you to save key-value pairs</p> <p>eg: localStorage.<strong>setItem</strong>('theme', 'dark');<br> localStorage.<strong>getItem</strong>('theme');</p> <p><strong>JSON.stringify()</strong> -> converts a JavaScript object, array, or primitive value into a JSON string.</p> <p>eg: const user = {<br> "name": "Alex",<br> "age": "28"</p> <p><strong>JSON.parse()</strong> ->JSON string and converts it into a JavaScript object or array.</p> <p>// A text string formatted as JSON<br> const jsonString = '{"name":"Alex","age":28,"isAdmin":true}';</p> <p>// Convert the string into a live JavaScript object<br> const userObj = JSON.parse(jsonString);</p> <p>console.log(userObj.name); // Output: "Alex"<br> console.log(userObj.age); // Output: 28<br> console.log(typeof userObj); // Output: "object"</p> <p>Synchronous -> One by one execution</p> <p>Asynchronous -> Simultaneously execution</p>
📰 Read the original article on Dev.to WebDev

Originally published by Dev.to WebDev. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.